From rdunlop@guralp.com Wed Apr 23 10:22:32 2008
Received: from a.painless.aaisp.net.uk ([81.187.30.51])
	by stoneboat.aleph1.co.uk with esmtps
	(TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63)
	(envelope-from <rdunlop@guralp.com>) id 1JobBA-000427-J8
	for yaffs@lists.aleph1.co.uk; Wed, 23 Apr 2008 10:22:31 +0100
Received: from home.pinkhut.co.uk ([81.187.28.34] helo=neddie.localdomain)
	by a.painless.aaisp.net.uk with esmtp (Exim 4.69)
	(envelope-from <rdunlop@guralp.com>) id 1JobB9-0004f1-QC
	for yaffs@lists.aleph1.co.uk; Wed, 23 Apr 2008 10:22:15 +0100
Received: by neddie.localdomain (Postfix, from userid 1000)
	id 8B05215E441; Wed, 23 Apr 2008 10:22:13 +0100 (BST)
Date: Wed, 23 Apr 2008 10:22:13 +0100
From: Bob Dunlop <rdunlop@guralp.com>
To: yaffs@lists.aleph1.co.uk
Message-ID: <20080423092213.GA29474@guralp.com>
Mail-Followup-To: yaffs@lists.aleph1.co.uk
References: <200803311550.12028.matthias.fuchs@esd-electronics.com>
	<47F12B4D.50402@googlemail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <47F12B4D.50402@googlemail.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
X-SA-Exim-Connect-IP: 81.187.30.51
X-SA-Exim-Mail-From: rdunlop@guralp.com
X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on
	stoneboat.aleph1.co.uk
X-Spam-Level: 
X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW
	autolearn=ham version=3.2.3
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on stoneboat.aleph1.co.uk)
Subject: Re: [Yaffs] yaffs with kernel 2.6.25: no more iget()
X-BeenThere: yaffs@lists.aleph1.co.uk
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion of YAFFS NAND flash filesystem <yaffs.lists.aleph1.co.uk>
List-Unsubscribe: <http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs>, 
	<mailto:yaffs-request@lists.aleph1.co.uk?subject=unsubscribe>
List-Archive: <http://lists.aleph1.co.uk/lurker/list/yaffs.html>
List-Post: <mailto:yaffs@lists.aleph1.co.uk>
List-Help: <mailto:yaffs-request@lists.aleph1.co.uk?subject=help>
List-Subscribe: <http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs>,
	<mailto:yaffs-request@lists.aleph1.co.uk?subject=subscribe>
X-List-Received-Date: Wed, 23 Apr 2008 09:22:32 -0000

Hi,

On Mon, Mar 31 at 08:19, Dirk Behme wrote:
> Matthias Fuchs wrote:
>> Hi,
>> did anybody spend some time in compiling yaffs for 2.6.25-rcX?
>> In February the iget() call got lost. So current yaffs does not compile in 
>> recent kernels anymore.
>
> Yes, you are right. With 2.6.25-rc6 I get
...
> Looking at the quite good patch comment, fixing this should be easy (?).
>
> Anybody with a patch?

Well I had to put YAFFS2 into the 2.6.25 kernel on Friday and this is the
naive patch I came up with based on the example changes.  It compiles and
works for me but I've only been using YAFFS for a total of 2 days.  I've
done little more than "it doesn't smoke" testing.


--- linux-2.6.git/fs/yaffs2/yaffs_fs.c-orig	2008-04-17 08:49:19.000000000 +0100
+++ linux-2.6.git/fs/yaffs2/yaffs_fs.c	2008-04-17 10:09:40.000000000 +0100
@@ -181,7 +181,7 @@
 #else
 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
 #endif
-static void yaffs_read_inode(struct inode *inode);
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino);
 
 static void yaffs_put_inode(struct inode *inode);
 static void yaffs_delete_inode(struct inode *);
@@ -284,7 +284,6 @@
 
 static struct super_operations yaffs_super_ops = {
 	.statfs = yaffs_statfs,
-	.read_inode = yaffs_read_inode,
 	.put_inode = yaffs_put_inode,
 	.put_super = yaffs_put_super,
 	.delete_inode = yaffs_delete_inode,
@@ -844,7 +843,9 @@
 	T(YAFFS_TRACE_OS,
 	  (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
 
-	inode = iget(sb, obj->objectId);
+	inode = yaffs_iget(sb, obj->objectId);
+	if (IS_ERR(inode))
+	    return NULL;
 
 	/* NB Side effect: iget calls back to yaffs_read_inode(). */
 	/* iget also increments the inode's i_count */
@@ -1427,19 +1428,25 @@
 }
 
 
-static void yaffs_read_inode(struct inode *inode)
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino)
 {
-	/* NB This is called as a side effect of other functions, but
-	 * we had to release the lock to prevent deadlocks, so
-	 * need to lock again.
-	 */
-
+	struct inode *inode;
 	yaffs_Object *obj;
-	yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
+	yaffs_Device *dev = yaffs_SuperToDevice(sb);
 
 	T(YAFFS_TRACE_OS,
-	  (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
+	  (KERN_DEBUG "yaffs_iget for %lu\n", ino));
 
+	inode = iget_locked(sb, ino);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+	if (!(inode->i_state & I_NEW))
+		return inode;
+
+	/* NB This is called as a side effect of other functions, but
+	 * we had to release the lock to prevent deadlocks, so
+	 * need to lock again.
+	 */
 	yaffs_GrossLock(dev);
 
 	obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
@@ -1447,6 +1454,9 @@
 	yaffs_FillInodeFromObject(inode, obj);
 
 	yaffs_GrossUnlock(dev);
+
+	unlock_new_inode(inode);
+	return inode;
 }
 
 static LIST_HEAD(yaffs_dev_list);

-- 
        Bob Dunlop
        Guralp Systems Limited
        http://www.guralp.com

