Skip to contentSkip to conversation

About direntries pointing to nowhere on reiserfs problem in 2.4

PATCH Oleg Drokin 10 participants 36 messages Feb 20, 2003 – Mar 3, 2003 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hello!

Vladimir have finally tracked the problem to a race between two iget4 running on same file whose inode is not in cache. The sequence of events is like this (UP case):
1st thread:
take inode_lock
search through inode cache, but found nothing. alloc new inode, mark it as locaked.
release inode_lock
call reiserfs_read_inode2().
do some stuff.
call search_by_key()
schedule()

Now 2nd thread comes in:
take inode_lock
search through inode cache, found inode with same inode number. check that there is find_actor defined for reiserfs.
call find_actor()
check that inode's primary key's dir_id is equal to expected one.
but at that time this part of inode is uninitialized yet! so we return 0;
...
And we create second inode for the same file.

This scenario seems possible for any filesystem that stores some "cookie" in private part of inode and whose read_inode2 can schedule. We checked and coda seems safe because they take a semaphore in iget().

So we solved that with patch below (Zygo, others who think they have this problem, please check).

But Vladimir is really unhappy with that comparison with zero and guessing (though he agrees it is correct, if FS is undamaged).

Andrew, Alan: Is there a possibility to have iget5_locked() kind of interface in 2.4? We need some way to init parts inode under inode_lock to solve this problem in more elegant way. (and inode_lock is not even exported, so I invented another spinlock to guard atomicity of inode pkey update on SMP).

Bye,
Oleg

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +24 -2
@@ -20,6 +20,10 @@
 static int reiserfs_get_block (struct inode * inode, long block,
 			       struct buffer_head * bh_result, int create);
 
+/* This spinlock guards inode pkey in private part of inode
+   against rae between find_actor() vs reiserfs_read_inode2 */
+static spinlock_t keycopy_lock = SPIN_LOCK_UNLOCKED;
+
 void reiserfs_delete_inode (struct inode * inode)
 {
     int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2; 
@@ -898,8 +902,9 @@
     bh = PATH_PLAST_BUFFER (path);
     ih = PATH_PITEM_HEAD (path);
 
-
+    spin_lock(&keycopy_lock);
     copy_key (INODE_PKEY (inode), &(ih->ih_key));
+    spin_unlock(&keycopy_lock);
     inode->i_blksize = PAGE_SIZE;
 
     INIT_LIST_HEAD(&inode->u.reiserfs_i.i_prealloc_list) ;
@@ -1220,10 +1225,27 @@
 				unsigned long inode_no, void *opaque )
 {
     struct reiserfs_iget4_args *args;
+    int retval;
 
     args = opaque;
+    /* We protect against possible parallel init_inode() on another CPU here. */
+    spin_lock(&keycopy_lock);
     /* args is already in CPU order */
-    return le32_to_cpu(INODE_PKEY(inode)->k_dir_id) == args -> objectid;
+    if (le32_to_cpu(INODE_PKEY(inode)->k_dir_id) == args -> objectid)
+	retval = 1;
+    else
+	/* If The key does not match, lets see if we are racing
+	   with another iget4, that already progressed so far
+	   to reiserfs_read_inode2() and was preempted in
+	   call to search_by_key(). The signs of that are:
+	     Inode is locked
+	     dirid and object id are zero (not yet initialized)*/
+	retval = (inode->i_state & I_LOCK) &&
+		 !INODE_PKEY(inode)->k_dir_id &&
+		 !INODE_PKEY(inode)->k_objectid;
+
+    spin_unlock(&keycopy_lock);
+    return retval;
 }
 
 struct inode * reiserfs_iget (struct super_block * s, const struct cpu_key * key)
#1 lore raw
Quoted 36 lines · Oleg Drokin

Hello!

Vladimir have finally tracked the problem to a race between two iget4 running on same file whose inode is not in cache. The sequence of events is like this (UP case):
1st thread:
take inode_lock
search through inode cache, but found nothing. alloc new inode, mark it as locaked.
release inode_lock
call reiserfs_read_inode2().
do some stuff.
call search_by_key()
schedule()

Now 2nd thread comes in:
take inode_lock
search through inode cache, found inode with same inode number. check that there is find_actor defined for reiserfs.
call find_actor()
check that inode's primary key's dir_id is equal to expected one.
but at that time this part of inode is uninitialized yet! so we return 0;
...
And we create second inode for the same file.

This scenario seems possible for any filesystem that stores some "cookie" in private part of inode and whose read_inode2 can schedule. We checked and coda seems safe because they take a semaphore in iget().

So we solved that with patch below (Zygo, others who think they have this problem, please check).

But Vladimir is really unhappy with that comparison with zero and guessing (though he agrees it is correct, if FS is undamaged).

Quoted 8 lines

Andrew, Alan: Is there a possibility to have iget5_locked() kind of interface in 2.4? We need some way to init parts inode under inode_lock to solve this problem in more elegant way. (and inode_lock is not even exported, so I invented another spinlock to guard atomicity of inode pkey update on SMP).

Bye,
Oleg

Hi!

Is this fix safe for usage already?

Chris, can you, please, put out the latency-related patch/diff soon for data=ordered mode?

Mmmh. I have some hangs within KDE 2.2.2 Konqueror when copying over (existing) directory links for some weeks now. I don't copy often over links but when it stalls, a directory link is somewhere involved. (No crashes, no messages in the logs, just "minutes" for copies or deletes that happened in seconds usually.)

Should I worry and use the patch
-- or finally upgrade my KDE ;-))

Thanks,

Manuel

P.S.: My kernel is 2.4.21-pre4 + all Chris' data-logging patches + preempt-patch for -pre1 (in that order).

[PATCH - direntry-fix.diff]

#2 lore raw

Hello!

Quoted 1 line · Manuel Krause

Is this fix safe for usage already?

work for me (tm) ;)
It will most probably will be replaced by iget5_locked, though.

Quoted 7 lines

Mmmh. I have some hangs within KDE 2.2.2 Konqueror when copying over (existing) directory links for some weeks now. I don't copy often over links but when it stalls, a directory link is somewhere involved. (No crashes, no messages in the logs, just "minutes" for copies or deletes that happened in seconds usually.)
Should I worry and use the patch
-- or finally upgrade my KDE ;-))

This does not look like this bug in reiserfs, the patch is supposed to fix.

Bye,
Oleg

#4 lore raw

2.4 iget5_locked port attempt to 2.4

In reply to a message not in the archive

Hello!

Quoted 5 lines · Andrew Morton
Quoted 2 lines

Andrew, Alan: Is there a possibility to have iget5_locked() kind of interface in 2.4?

iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.
Backporting that to 2.4 would be the ideal solution, IMO.

Ok, here is my simple attempt. I just took a patch from early 2.5 days by [email protected] ;)

Coda changes are not tested, but look correct.
NFS changes are non-working ones, but I am going to sleep now and may be somebody in different timezone would fix that while I am sleeping. ;) If fixes won't appear by tomorrow, I would look into that myself then.
reiserfs changes are working ones. Tested by me. :)

Patch is against latest 2.4 bk tree.

Bye,
Oleg

===== Documentation/filesystems/Locking 1.7 vs edited =====

Documentation/filesystems/Locking +1 -1
@@ -114,7 +114,7 @@
 remount_fs:	yes	yes	maybe		(see below)
 umount_begin:	yes	no	maybe		(see below)
 
-->read_inode() is not a method - it's a callback used in iget()/iget4().
+->read_inode() is not a method - it's a callback used in iget().
 rules for mount_sem are not too nice - it is going to die and be replaced
 by better scheme anyway.
 

===== fs/Makefile 1.16 vs edited =====

fs/Makefile +1 -1
@@ -7,7 +7,7 @@
 
 O_TARGET := fs.o
 
-export-objs :=	filesystems.o open.o dcache.o buffer.o
+export-objs :=	filesystems.o open.o dcache.o buffer.o inode.o
 mod-subdirs :=	nls
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \

===== fs/inode.c 1.36 vs edited =====

fs/inode.c +148 -38

271 lines not on this page · raw message

===== fs/coda/cnode.c 1.8 vs edited =====

fs/coda/cnode.c +4 -7
@@ -27,11 +27,6 @@
 	return 1;
 }
 
-static int coda_inocmp(struct inode *inode, unsigned long ino, void *opaque)
-{
-	return (coda_fideq((ViceFid *)opaque, &(ITOC(inode)->c_fid)));
-}
-
 static struct inode_operations coda_symlink_inode_operations = {
 	readlink:	page_readlink,
 	follow_link:	page_follow_link,
@@ -129,6 +124,7 @@
 		      struct ViceFid *newfid)
 {
 	struct coda_inode_info *cii;
+	unsigned long hash = coda_f2i(newfid);
 	
 	cii = ITOC(inode);
 
@@ -191,8 +187,9 @@
 {
 	int error = 0;
 
-	*inode = iget(sb, CTL_INO);
-	if ( *inode ) {
+	*inode = new_inode(sb);
+	if (*inode) {
+		(*inode)->i_ino = CTL_INO;
 		(*inode)->i_op = &coda_ioctl_inode_operations;
 		(*inode)->i_fop = &coda_ioctl_operations;
 		(*inode)->i_mode = 0444;

===== fs/nfs/inode.c 1.18 vs edited =====

fs/nfs/inode.c +25 -10
@@ -45,7 +45,6 @@
 void nfs_zap_caches(struct inode *);
 static void nfs_invalidate_inode(struct inode *);
 
-static void nfs_read_inode(struct inode *);
 static void nfs_write_inode(struct inode *,int);
 static void nfs_delete_inode(struct inode *);
 static void nfs_put_super(struct super_block *);
@@ -55,7 +54,6 @@
 static int  nfs_show_options(struct seq_file *, struct vfsmount *);
 
 static struct super_operations nfs_sops = { 
-	read_inode:	nfs_read_inode,
 	write_inode:	nfs_write_inode,
 	delete_inode:	nfs_delete_inode,
 	put_super:	nfs_put_super,
@@ -634,7 +632,7 @@
 	 * do this once. (We don't allow inodes to change types.)
 	 */
 	if (inode->i_mode == 0) {
-		NFS_FILEID(inode) = fattr->fileid;
+//		NFS_FILEID(inode) = fattr->fileid;
 		inode->i_mode = fattr->mode;
 		/* Why so? Because we want revalidate for devices/FIFOs, and
 		 * that's precisely what we have in nfs_file_inode_operations.
@@ -650,9 +648,9 @@
 			inode->i_op = &nfs_symlink_inode_operations;
 		else
 			init_special_inode(inode, inode->i_mode, fattr->rdev);
-		memcpy(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh));
+//		memcpy(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh));
 	}
-	nfs_refresh_inode(inode, fattr);
+//	nfs_refresh_inode(inode, fattr);
 }
 
 struct nfs_find_desc {
@@ -667,7 +665,7 @@
  * i_ino.
  */
 static int
-nfs_find_actor(struct inode *inode, unsigned long ino, void *opaque)
+nfs_find_actor(struct inode *inode, void *opaque)
 {
 	struct nfs_find_desc	*desc = (struct nfs_find_desc *)opaque;
 	struct nfs_fh		*fh = desc->fh;
@@ -685,6 +683,18 @@
 	return 1;
 }
 
+static int
+nfs_init_locked(struct inode *inode, void *opaque)
+{
+	struct nfs_find_desc	*desc = (struct nfs_find_desc *)opaque;
+	struct nfs_fh		*fh = desc->fh;
+	struct nfs_fattr	*fattr = desc->fattr;
+
+	NFS_FILEID(inode) = fattr->fileid;
+	memcpy(NFS_FH(inode), fh, sizeof(struct nfs_fh));
+	return 0;
+}
+
 /*
  * This is our own version of iget that looks up inodes by file handle
  * instead of inode number.  We use this technique instead of using
@@ -712,7 +722,7 @@
 {
 	struct nfs_find_desc desc = { fh, fattr };
 	struct inode *inode = NULL;
-	unsigned long ino;
+	unsigned long hash;
 
 	if ((fattr->valid & NFS_ATTR_FATTR) == 0)
 		goto out_no_inode;
@@ -722,12 +732,17 @@
 		goto out_no_inode;
 	}
 
-	ino = nfs_fattr_to_ino_t(fattr);
+	hash = nfs_fattr_to_ino_t(fattr);
 
-	if (!(inode = iget4(sb, ino, nfs_find_actor, &desc)))
+	if (!(inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc)))
 		goto out_no_inode;
 
-	nfs_fill_inode(inode, fh, fattr);
+        if (inode->i_state & I_NEW) {
+		inode->i_ino = hash;
+		nfs_fill_inode(inode, fh, fattr);
+		unlock_new_inode(inode);
+	} else
+		nfs_refresh_inode(inode, fattr);
 	dprintk("NFS: __nfs_fhget(%x/%Ld ct=%d)\n",
 		inode->i_dev, (long long)NFS_FILEID(inode),
 		atomic_read(&inode->i_count));

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +29 -27

122 lines not on this page · raw message

===== fs/reiserfs/super.c 1.27 vs edited =====

fs/reiserfs/super.c +9 -5
@@ -381,8 +381,6 @@
 
 struct super_operations reiserfs_sops = 
 {
-  read_inode: reiserfs_read_inode,
-  read_inode2: reiserfs_read_inode2,
   write_inode: reiserfs_write_inode,
   dirty_inode: reiserfs_dirty_inode,
   delete_inode: reiserfs_delete_inode,
@@ -1117,7 +1115,7 @@
     int old_format = 0;
     unsigned long blocks;
     int jinit_done = 0 ;
-    struct reiserfs_iget4_args args ;
+    struct reiserfs_iget_args args ;
     int old_magic;
     struct reiserfs_super_block * rs;
 
@@ -1194,11 +1192,17 @@
         printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
 	s->s_flags |= MS_RDONLY ;
     }
-    args.objectid = REISERFS_ROOT_PARENT_OBJECTID ;
-    root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args));
+    args.objectid = REISERFS_ROOT_OBJECTID ;
+    args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
+    root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
     if (!root_inode) {
 	printk ("reiserfs_read_super: get root inode failed\n");
 	goto error;
+    }
+ 
+    if (root_inode->i_state & I_NEW) {
+	reiserfs_read_locked_inode(root_inode, &args);
+	unlock_new_inode(root_inode);
     }
 
     s->s_root = d_alloc_root(root_inode);  

===== include/linux/fs.h 1.74 vs edited =====

include/linux/fs.h +18 -11
@@ -885,13 +885,6 @@
 
 	void (*read_inode) (struct inode *);
   
-  	/* reiserfs kludge.  reiserfs needs 64 bits of information to
-    	** find an inode.  We are using the read_inode2 call to get
-   	** that information.  We don't like this, and are waiting on some
-   	** VFS changes for the real solution.
-   	** iget4 calls read_inode2, iff it is defined
-   	*/
-    	void (*read_inode2) (struct inode *, void *) ;
    	void (*dirty_inode) (struct inode *);
 	void (*write_inode) (struct inode *, int);
 	void (*put_inode) (struct inode *);
@@ -940,6 +933,7 @@
 #define I_LOCK			8
 #define I_FREEING		16
 #define I_CLEAR			32
+#define I_NEW			64
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 
@@ -1378,19 +1372,32 @@
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 
-typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
-extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
+extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+extern void unlock_new_inode(struct inode *);
+
 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
 {
-	return iget4(sb, ino, NULL, NULL);
+	struct inode *inode = iget_locked(sb, ino);
+
+	if (inode && (inode->i_state & I_NEW)) {
+		sb->s_op->read_inode(inode);
+		unlock_new_inode(inode);
+	}
+
+	return inode;
 }
 
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *sb);
 extern void remove_suid(struct inode *inode);
 
-extern void insert_inode_hash(struct inode *);
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+	__insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern struct buffer_head * get_hash_table(kdev_t, int, int);

===== include/linux/reiserfs_fs.h 1.26 vs edited =====

include/linux/reiserfs_fs.h +5 -3
@@ -1478,8 +1478,9 @@
 #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
 #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
 
-struct reiserfs_iget4_args {
+struct reiserfs_iget_args {
     __u32 objectid ;
+    __u32 dirid ;
 } ;
 
 /***************************************************************************/
@@ -1730,8 +1731,9 @@
 
 /* inode.c */
 
-void reiserfs_read_inode (struct inode * inode) ;
-void reiserfs_read_inode2(struct inode * inode, void *p) ;
+void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
+int reiserfs_find_actor(struct inode * inode, void *p) ;
+int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
 void reiserfs_delete_inode (struct inode * inode);
 void reiserfs_write_inode (struct inode * inode, int) ;
 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data,

===== kernel/ksyms.c 1.67 vs edited =====

kernel/ksyms.c +1 -2
@@ -140,7 +140,6 @@
 EXPORT_SYMBOL(fget);
 EXPORT_SYMBOL(igrab);
 EXPORT_SYMBOL(iunique);
-EXPORT_SYMBOL(iget4);
 EXPORT_SYMBOL(iput);
 EXPORT_SYMBOL(inode_init_once);
 EXPORT_SYMBOL(force_delete);
@@ -528,7 +527,7 @@
 EXPORT_SYMBOL(read_ahead);
 EXPORT_SYMBOL(get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);
maintainer
#5 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Quoted 2 lines · Oleg Drokin

Ok, here is my simple attempt. I just took a patch from early 2.5 days by [email protected] ;)

Nice to see that it is being considered for a backport to 2.4, that would allow me to get rid of the lock around the call to iget4.

Why didn't you take the final version that was sent to Linus? It was against 2.5.14, but should be pretty close for 2.4.x. You can find it at http://delft.aura.cs.cmu.edu/icreate/, both broken up in small steps, and as one big patch.

As far as I know, the only change/improvement that went into 2.5 at a later time was the ilookup code.

Quoted 1 line

Coda changes are not tested, but look correct.

Those Coda changes are not correct as we really need to use iget4 (or in the new code, iget5_locked). That patch looks like it won't even compile, coda_inocmp is simply removed while it is still used by the two calls to iget4 that you didn't replace with iget5_locked. Let alone adding the inode initializer. I also don't know why you are adding an unused local variable to coda_replace_fid.

Jan

#6 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Hello!

Quoted 4 lines · Jan Harkes
Quoted 2 lines

Ok, here is my simple attempt. I just took a patch from early 2.5 days by [email protected] ;)

Nice to see that it is being considered for a backport to 2.4, that would allow me to get rid of the lock around the call to iget4.

That's because we do not want to use this kind of lock in iget for reiserfs ;)

Quoted 1 line

Why didn't you take the final version that was sent to Linus? It was

I did. I extracted these patches from bitkeeper.

Quoted 1 line

against 2.5.14, but should be pretty close for 2.4.x. You can find

Still there were lots of differences in coda and especially nfs.

Quoted 2 lines

it at http://delft.aura.cs.cmu.edu/icreate/, both broken up in small steps, and as one big patch.

They should be the same as those accepted by Linus, no?

Quoted 4 lines
Quoted 1 line

Coda changes are not tested, but look correct.

Those Coda changes are not correct as we really need to use iget4 (or in the new code, iget5_locked). That patch looks like it won't even compile, coda_inocmp is simply removed while it is still used by the two

It compiles. At least I checked that and it compiled for me.

Quoted 1 line

calls to iget4 that you didn't replace with iget5_locked. Let alone

Hm?
Probably I sent wron patch.

Quoted 2 lines

adding the inode initializer. I also don't know why you are adding an unused local variable to coda_replace_fid.

Ah, stupid me.
That was previous version of the patch without some rejects applied manually by me. Look at this version below ;)
Sorry.

Bye,
Oleg

===== Documentation/filesystems/Locking 1.7 vs edited =====

Documentation/filesystems/Locking +1 -1
@@ -114,7 +114,7 @@
 remount_fs:	yes	yes	maybe		(see below)
 umount_begin:	yes	no	maybe		(see below)
 
-->read_inode() is not a method - it's a callback used in iget()/iget4().
+->read_inode() is not a method - it's a callback used in iget().
 rules for mount_sem are not too nice - it is going to die and be replaced
 by better scheme anyway.
 

===== fs/Makefile 1.16 vs edited =====

fs/Makefile +1 -1
@@ -7,7 +7,7 @@
 
 O_TARGET := fs.o
 
-export-objs :=	filesystems.o open.o dcache.o buffer.o
+export-objs :=	filesystems.o open.o dcache.o buffer.o inode.o
 mod-subdirs :=	nls
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \

===== fs/inode.c 1.36 vs edited =====

fs/inode.c +148 -38

271 lines not on this page · raw message

===== fs/coda/cnode.c 1.8 vs edited =====

fs/coda/cnode.c +41 -47

151 lines not on this page · raw message

===== fs/coda/inode.c 1.9 vs edited =====

fs/coda/inode.c +0 -20
@@ -34,7 +34,6 @@
 
 /* VFS super_block ops */
 static struct super_block *coda_read_super(struct super_block *, void *, int);
-static void coda_read_inode(struct inode *);
 static void coda_clear_inode(struct inode *);
 static void coda_put_super(struct super_block *);
 static int coda_statfs(struct super_block *sb, struct statfs *buf);
@@ -42,7 +41,6 @@
 /* exported operations */
 struct super_operations coda_super_operations =
 {
-	read_inode:	coda_read_inode,
 	clear_inode:	coda_clear_inode,
 	put_super:	coda_put_super,
 	statfs:		coda_statfs,
@@ -179,24 +177,6 @@
 
 	printk("Coda: Bye bye.\n");
 	kfree(sbi);
-}
-
-/* all filling in of inodes postponed until lookup */
-static void coda_read_inode(struct inode *inode)
-{
-	struct coda_sb_info *sbi = coda_sbp(inode->i_sb);
-	struct coda_inode_info *cii;
-
-        if (!sbi) BUG();
-
-	cii = ITOC(inode);
-	if (!coda_isnullfid(&cii->c_fid)) {
-            printk("coda_read_inode: initialized inode");
-            return;
-        }
-
-	cii->c_mapcount = 0;
-	list_add(&cii->c_cilist, &sbi->sbi_cihead);
 }
 
 static void coda_clear_inode(struct inode *inode)

===== fs/nfs/inode.c 1.18 vs edited =====

fs/nfs/inode.c +25 -10
@@ -45,7 +45,6 @@
 void nfs_zap_caches(struct inode *);
 static void nfs_invalidate_inode(struct inode *);
 
-static void nfs_read_inode(struct inode *);
 static void nfs_write_inode(struct inode *,int);
 static void nfs_delete_inode(struct inode *);
 static void nfs_put_super(struct super_block *);
@@ -55,7 +54,6 @@
 static int  nfs_show_options(struct seq_file *, struct vfsmount *);
 
 static struct super_operations nfs_sops = { 
-	read_inode:	nfs_read_inode,
 	write_inode:	nfs_write_inode,
 	delete_inode:	nfs_delete_inode,
 	put_super:	nfs_put_super,
@@ -634,7 +632,7 @@
 	 * do this once. (We don't allow inodes to change types.)
 	 */
 	if (inode->i_mode == 0) {
-		NFS_FILEID(inode) = fattr->fileid;
+//		NFS_FILEID(inode) = fattr->fileid;
 		inode->i_mode = fattr->mode;
 		/* Why so? Because we want revalidate for devices/FIFOs, and
 		 * that's precisely what we have in nfs_file_inode_operations.
@@ -650,9 +648,9 @@
 			inode->i_op = &nfs_symlink_inode_operations;
 		else
 			init_special_inode(inode, inode->i_mode, fattr->rdev);
-		memcpy(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh));
+//		memcpy(&inode->u.nfs_i.fh, fh, sizeof(inode->u.nfs_i.fh));
 	}
-	nfs_refresh_inode(inode, fattr);
+//	nfs_refresh_inode(inode, fattr);
 }
 
 struct nfs_find_desc {
@@ -667,7 +665,7 @@
  * i_ino.
  */
 static int
-nfs_find_actor(struct inode *inode, unsigned long ino, void *opaque)
+nfs_find_actor(struct inode *inode, void *opaque)
 {
 	struct nfs_find_desc	*desc = (struct nfs_find_desc *)opaque;
 	struct nfs_fh		*fh = desc->fh;
@@ -685,6 +683,18 @@
 	return 1;
 }
 
+static int
+nfs_init_locked(struct inode *inode, void *opaque)
+{
+	struct nfs_find_desc	*desc = (struct nfs_find_desc *)opaque;
+	struct nfs_fh		*fh = desc->fh;
+	struct nfs_fattr	*fattr = desc->fattr;
+
+	NFS_FILEID(inode) = fattr->fileid;
+	memcpy(NFS_FH(inode), fh, sizeof(struct nfs_fh));
+	return 0;
+}
+
 /*
  * This is our own version of iget that looks up inodes by file handle
  * instead of inode number.  We use this technique instead of using
@@ -712,7 +722,7 @@
 {
 	struct nfs_find_desc desc = { fh, fattr };
 	struct inode *inode = NULL;
-	unsigned long ino;
+	unsigned long hash;
 
 	if ((fattr->valid & NFS_ATTR_FATTR) == 0)
 		goto out_no_inode;
@@ -722,12 +732,17 @@
 		goto out_no_inode;
 	}
 
-	ino = nfs_fattr_to_ino_t(fattr);
+	hash = nfs_fattr_to_ino_t(fattr);
 
-	if (!(inode = iget4(sb, ino, nfs_find_actor, &desc)))
+	if (!(inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc)))
 		goto out_no_inode;
 
-	nfs_fill_inode(inode, fh, fattr);
+        if (inode->i_state & I_NEW) {
+		inode->i_ino = hash;
+		nfs_fill_inode(inode, fh, fattr);
+		unlock_new_inode(inode);
+	} else
+		nfs_refresh_inode(inode, fattr);
 	dprintk("NFS: __nfs_fhget(%x/%Ld ct=%d)\n",
 		inode->i_dev, (long long)NFS_FILEID(inode),
 		atomic_read(&inode->i_count));

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +29 -27

122 lines not on this page · raw message

===== fs/reiserfs/super.c 1.27 vs edited =====

fs/reiserfs/super.c +9 -5
@@ -381,8 +381,6 @@
 
 struct super_operations reiserfs_sops = 
 {
-  read_inode: reiserfs_read_inode,
-  read_inode2: reiserfs_read_inode2,
   write_inode: reiserfs_write_inode,
   dirty_inode: reiserfs_dirty_inode,
   delete_inode: reiserfs_delete_inode,
@@ -1117,7 +1115,7 @@
     int old_format = 0;
     unsigned long blocks;
     int jinit_done = 0 ;
-    struct reiserfs_iget4_args args ;
+    struct reiserfs_iget_args args ;
     int old_magic;
     struct reiserfs_super_block * rs;
 
@@ -1194,11 +1192,17 @@
         printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
 	s->s_flags |= MS_RDONLY ;
     }
-    args.objectid = REISERFS_ROOT_PARENT_OBJECTID ;
-    root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args));
+    args.objectid = REISERFS_ROOT_OBJECTID ;
+    args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
+    root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
     if (!root_inode) {
 	printk ("reiserfs_read_super: get root inode failed\n");
 	goto error;
+    }
+ 
+    if (root_inode->i_state & I_NEW) {
+	reiserfs_read_locked_inode(root_inode, &args);
+	unlock_new_inode(root_inode);
     }
 
     s->s_root = d_alloc_root(root_inode);  

===== include/linux/fs.h 1.74 vs edited =====

include/linux/fs.h +18 -11
@@ -885,13 +885,6 @@
 
 	void (*read_inode) (struct inode *);
   
-  	/* reiserfs kludge.  reiserfs needs 64 bits of information to
-    	** find an inode.  We are using the read_inode2 call to get
-   	** that information.  We don't like this, and are waiting on some
-   	** VFS changes for the real solution.
-   	** iget4 calls read_inode2, iff it is defined
-   	*/
-    	void (*read_inode2) (struct inode *, void *) ;
    	void (*dirty_inode) (struct inode *);
 	void (*write_inode) (struct inode *, int);
 	void (*put_inode) (struct inode *);
@@ -940,6 +933,7 @@
 #define I_LOCK			8
 #define I_FREEING		16
 #define I_CLEAR			32
+#define I_NEW			64
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 
@@ -1378,19 +1372,32 @@
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 
-typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
-extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
+extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+extern void unlock_new_inode(struct inode *);
+
 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
 {
-	return iget4(sb, ino, NULL, NULL);
+	struct inode *inode = iget_locked(sb, ino);
+
+	if (inode && (inode->i_state & I_NEW)) {
+		sb->s_op->read_inode(inode);
+		unlock_new_inode(inode);
+	}
+
+	return inode;
 }
 
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *sb);
 extern void remove_suid(struct inode *inode);
 
-extern void insert_inode_hash(struct inode *);
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+	__insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern struct buffer_head * get_hash_table(kdev_t, int, int);

===== include/linux/reiserfs_fs.h 1.26 vs edited =====

include/linux/reiserfs_fs.h +5 -3
@@ -1478,8 +1478,9 @@
 #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
 #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
 
-struct reiserfs_iget4_args {
+struct reiserfs_iget_args {
     __u32 objectid ;
+    __u32 dirid ;
 } ;
 
 /***************************************************************************/
@@ -1730,8 +1731,9 @@
 
 /* inode.c */
 
-void reiserfs_read_inode (struct inode * inode) ;
-void reiserfs_read_inode2(struct inode * inode, void *p) ;
+void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
+int reiserfs_find_actor(struct inode * inode, void *p) ;
+int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
 void reiserfs_delete_inode (struct inode * inode);
 void reiserfs_write_inode (struct inode * inode, int) ;
 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data,

===== kernel/ksyms.c 1.67 vs edited =====

kernel/ksyms.c +1 -2
@@ -140,7 +140,6 @@
 EXPORT_SYMBOL(fget);
 EXPORT_SYMBOL(igrab);
 EXPORT_SYMBOL(iunique);
-EXPORT_SYMBOL(iget4);
 EXPORT_SYMBOL(iput);
 EXPORT_SYMBOL(inode_init_once);
 EXPORT_SYMBOL(force_delete);
@@ -528,7 +527,7 @@
 EXPORT_SYMBOL(read_ahead);
 EXPORT_SYMBOL(get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);
#7 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

In reply to Jan Harkes

Hello!

Ok, here's iget5_locked backport version that works for me. NFS client works the same way as unpatched 2.4.21-pre4 from current bk tree.
(ie with it I still ocasionally see fsx produsing "short read" or "Size error: expected 0x1b9ac stat 0x1b9ac seek 0x23078" or "read i/o error". fsstress comsistently produces tons of "RPC request reserved 1144 but used XXXX" kind of messages with and without this patch. (server is vanilla 2.4.20)). Coda changes are verified to compile, but since I do not have coda server, I cannot test the changes.
Reiserfs changes are also seems to be working.

Original patch was from Jan Harkes <[email protected]>, and was applied somewhere at the beginning of 2.5 development.
It still would be nice if someone more knowledgeable in NFS client code will review the changes (and the same is true for Coda of course).

Bye,
Oleg

===== Documentation/filesystems/Locking 1.7 vs edited =====

Documentation/filesystems/Locking +1 -1
@@ -114,7 +114,7 @@
 remount_fs:	yes	yes	maybe		(see below)
 umount_begin:	yes	no	maybe		(see below)
 
-->read_inode() is not a method - it's a callback used in iget()/iget4().
+->read_inode() is not a method - it's a callback used in iget().
 rules for mount_sem are not too nice - it is going to die and be replaced
 by better scheme anyway.
 

===== fs/Makefile 1.16 vs edited =====

fs/Makefile +1 -1
@@ -7,7 +7,7 @@
 
 O_TARGET := fs.o
 
-export-objs :=	filesystems.o open.o dcache.o buffer.o
+export-objs :=	filesystems.o open.o dcache.o buffer.o inode.o
 mod-subdirs :=	nls
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \

===== fs/inode.c 1.36 vs edited =====

fs/inode.c +148 -38

271 lines not on this page · raw message

===== fs/coda/cnode.c 1.8 vs edited =====

fs/coda/cnode.c +41 -47

151 lines not on this page · raw message

===== fs/coda/inode.c 1.9 vs edited =====

fs/coda/inode.c +0 -20
@@ -34,7 +34,6 @@
 
 /* VFS super_block ops */
 static struct super_block *coda_read_super(struct super_block *, void *, int);
-static void coda_read_inode(struct inode *);
 static void coda_clear_inode(struct inode *);
 static void coda_put_super(struct super_block *);
 static int coda_statfs(struct super_block *sb, struct statfs *buf);
@@ -42,7 +41,6 @@
 /* exported operations */
 struct super_operations coda_super_operations =
 {
-	read_inode:	coda_read_inode,
 	clear_inode:	coda_clear_inode,
 	put_super:	coda_put_super,
 	statfs:		coda_statfs,
@@ -179,24 +177,6 @@
 
 	printk("Coda: Bye bye.\n");
 	kfree(sbi);
-}
-
-/* all filling in of inodes postponed until lookup */
-static void coda_read_inode(struct inode *inode)
-{
-	struct coda_sb_info *sbi = coda_sbp(inode->i_sb);
-	struct coda_inode_info *cii;
-
-        if (!sbi) BUG();
-
-	cii = ITOC(inode);
-	if (!coda_isnullfid(&cii->c_fid)) {
-            printk("coda_read_inode: initialized inode");
-            return;
-        }
-
-	cii->c_mapcount = 0;
-	list_add(&cii->c_cilist, &sbi->sbi_cihead);
 }
 
 static void coda_clear_inode(struct inode *inode)

===== fs/nfs/inode.c 1.18 vs edited =====

fs/nfs/inode.c +34 -34

126 lines not on this page · raw message

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +29 -27

122 lines not on this page · raw message

===== fs/reiserfs/super.c 1.27 vs edited =====

fs/reiserfs/super.c +9 -5
@@ -381,8 +381,6 @@
 
 struct super_operations reiserfs_sops = 
 {
-  read_inode: reiserfs_read_inode,
-  read_inode2: reiserfs_read_inode2,
   write_inode: reiserfs_write_inode,
   dirty_inode: reiserfs_dirty_inode,
   delete_inode: reiserfs_delete_inode,
@@ -1117,7 +1115,7 @@
     int old_format = 0;
     unsigned long blocks;
     int jinit_done = 0 ;
-    struct reiserfs_iget4_args args ;
+    struct reiserfs_iget_args args ;
     int old_magic;
     struct reiserfs_super_block * rs;
 
@@ -1194,11 +1192,17 @@
         printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
 	s->s_flags |= MS_RDONLY ;
     }
-    args.objectid = REISERFS_ROOT_PARENT_OBJECTID ;
-    root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args));
+    args.objectid = REISERFS_ROOT_OBJECTID ;
+    args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
+    root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
     if (!root_inode) {
 	printk ("reiserfs_read_super: get root inode failed\n");
 	goto error;
+    }
+ 
+    if (root_inode->i_state & I_NEW) {
+	reiserfs_read_locked_inode(root_inode, &args);
+	unlock_new_inode(root_inode);
     }
 
     s->s_root = d_alloc_root(root_inode);  

===== include/linux/fs.h 1.74 vs edited =====

include/linux/fs.h +18 -11
@@ -885,13 +885,6 @@
 
 	void (*read_inode) (struct inode *);
   
-  	/* reiserfs kludge.  reiserfs needs 64 bits of information to
-    	** find an inode.  We are using the read_inode2 call to get
-   	** that information.  We don't like this, and are waiting on some
-   	** VFS changes for the real solution.
-   	** iget4 calls read_inode2, iff it is defined
-   	*/
-    	void (*read_inode2) (struct inode *, void *) ;
    	void (*dirty_inode) (struct inode *);
 	void (*write_inode) (struct inode *, int);
 	void (*put_inode) (struct inode *);
@@ -940,6 +933,7 @@
 #define I_LOCK			8
 #define I_FREEING		16
 #define I_CLEAR			32
+#define I_NEW			64
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 
@@ -1378,19 +1372,32 @@
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 
-typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
-extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
+extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+extern void unlock_new_inode(struct inode *);
+
 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
 {
-	return iget4(sb, ino, NULL, NULL);
+	struct inode *inode = iget_locked(sb, ino);
+
+	if (inode && (inode->i_state & I_NEW)) {
+		sb->s_op->read_inode(inode);
+		unlock_new_inode(inode);
+	}
+
+	return inode;
 }
 
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *sb);
 extern void remove_suid(struct inode *inode);
 
-extern void insert_inode_hash(struct inode *);
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+	__insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern struct buffer_head * get_hash_table(kdev_t, int, int);

===== include/linux/reiserfs_fs.h 1.26 vs edited =====

include/linux/reiserfs_fs.h +5 -3
@@ -1478,8 +1478,9 @@
 #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
 #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
 
-struct reiserfs_iget4_args {
+struct reiserfs_iget_args {
     __u32 objectid ;
+    __u32 dirid ;
 } ;
 
 /***************************************************************************/
@@ -1730,8 +1731,9 @@
 
 /* inode.c */
 
-void reiserfs_read_inode (struct inode * inode) ;
-void reiserfs_read_inode2(struct inode * inode, void *p) ;
+void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
+int reiserfs_find_actor(struct inode * inode, void *p) ;
+int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
 void reiserfs_delete_inode (struct inode * inode);
 void reiserfs_write_inode (struct inode * inode, int) ;
 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data,

===== kernel/ksyms.c 1.67 vs edited =====

kernel/ksyms.c +1 -2
@@ -140,7 +140,6 @@
 EXPORT_SYMBOL(fget);
 EXPORT_SYMBOL(igrab);
 EXPORT_SYMBOL(iunique);
-EXPORT_SYMBOL(iget4);
 EXPORT_SYMBOL(iput);
 EXPORT_SYMBOL(inode_init_once);
 EXPORT_SYMBOL(force_delete);
@@ -528,7 +527,7 @@
 EXPORT_SYMBOL(read_ahead);
 EXPORT_SYMBOL(get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);
#8 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Oleg Drokin <[email protected]> writes:

     >     Original patch was from Jan Harkes <[email protected]>,
     >     and was applied somewhere at the beginning of 2.5
     >     development.  It still would be nice if someone more
     >     knowledgeable in NFS client code will review the changes
     >     (and the same is true for Coda of course).

Please remind me. Why can't NFS set inode->i_mode, call nfs_fill_inode() etc. in the 'init_locked' callback?

As for the issue of the stat() problem you mentioned: does your server have a monotonically increasing inode->i_ctime? If ntp or something like that keeps turning the clock backward on the server, then the NFS client has no chance of recognizing which attribute updates are the more recent ones.

Cheers,
Trond

#9 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

" " == Trond Myklebust <[email protected]> writes:

" " == Oleg Drokin <[email protected]> writes:

> Please remind me. Why can't NFS set inode->i_mode, call > nfs_fill_inode() etc. in the 'init_locked' callback?

Duh, forget that question. The latter is called with the global inode lock held which you want to release asap.

Cheers,
Trond

#10 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

In reply to Trond Myklebust

Hello!

Quoted 7 lines · Trond Myklebust
     >     Original patch was from Jan Harkes <[email protected]>,
     >     and was applied somewhere at the beginning of 2.5
     >     development.  It still would be nice if someone more
     >     knowledgeable in NFS client code will review the changes
     >     (and the same is true for Coda of course).

Please remind me. Why can't NFS set inode->i_mode, call nfs_fill_inode() etc. in the 'init_locked' callback?

Well, it seems there is no reason against that.

Quoted 2 lines

As for the issue of the stat() problem you mentioned: does your server have a monotonically increasing inode->i_ctime? If ntp or something

I think it have.

Quoted 3 lines

like that keeps turning the clock backward on the server, then the NFS client has no chance of recognizing which attribute updates are the more recent ones.

Ok, I stopped ntpd. Will see what will happen. ;)
Aha, it died already:
doread: read: Input/output error

How about that "RPC request reserved 1144 but used 4024" alike stuff"?

Bye,
Oleg

#11 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Oleg Drokin <[email protected]> writes:

like that keeps turning the clock backward on the server, then the NFS client has no chance of recognizing which attribute updates are the more recent ones.

> Ok, I stopped ntpd. Will see what will happen. ;) Aha, it died > already: doread: read: Input/output error

Silly question: Are you perhaps testing using the 'soft' mount option?

> How about that "RPC request reserved 1144 but used 4024" alike > stuff"?

Sounds like Neil made another accounting error in the server code 8-). Can you try to check on which type of request it occurs (readdir, read, readlink?).

Cheers,
Trond

#12 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Hello!

Quoted 6 lines · Trond Myklebust
Quoted 3 lines
Quoted 3 lines

like that keeps turning the clock backward on the server, then the NFS client has no chance of recognizing which attribute updates are the more recent ones.

> Ok, I stopped ntpd. Will see what will happen. ;) Aha, it died > already: doread: read: Input/output error
Silly question: Are you perhaps testing using the 'soft' mount option?

Hm. I just mount it as
mount server:/tmp /mnt -t nfs
no extra options. So I guess no, I do not have wthis soft stuff.

Quoted 5 lines

> How about that "RPC request reserved 1144 but used 4024" alike > stuff"?
Sounds like Neil made another accounting error in the server code 8-). Can you try to check on which type of request it occurs (readdir, read, readlink?).

Ok. Will try (I guess I need to do this on latest 2.4 kernel anyway. (my nfs server is running 2.4.20)).

Bye,
Oleg

#13 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Oleg Drokin <[email protected]> writes:

> Hello! On Mon, Feb 24, 2003 at 06:17:30PM +0100, Trond > Myklebust wrote:
>> >> like that keeps turning the clock backward on the server, >> >> then the NFS client has no chance of recognizing which >> >> attribute updates are the more recent ones.
>> > Ok, I stopped ntpd. Will see what will happen. ;) Aha, it >> > died already: doread: read: Input/output error
>> Silly question: Are you perhaps testing using the 'soft' mount >> option?

> Hm. I just mount it as mount server:/tmp /mnt -t nfs no extra > options. So I guess no, I do not have wthis soft stuff.

...and there were no accompanying messages logged by syslog? In principle the NFS client is always supposed to supply an error message when it generates an EIO.

Cheers,
Trond

#14 lore raw

Re: 2.4 iget5_locked port attempt to 2.4 (supposedly fixed NFS version this time)

Hello!

Quoted 4 lines · Trond Myklebust

> Hello! On Mon, Feb 24, 2003 at 06:17:30PM +0100, Trond > Myklebust wrote:
>> >> like that keeps turning the clock backward on the server, >> >> then the NFS client has no chance of recognizing which

Quoted 8 lines

>> >> attribute updates are the more recent ones.
>> > Ok, I stopped ntpd. Will see what will happen. ;) Aha, it >> > died already: doread: read: Input/output error
>> Silly question: Are you perhaps testing using the 'soft' mount >> option?
> Hm. I just mount it as mount server:/tmp /mnt -t nfs no extra > options. So I guess no, I do not have wthis soft stuff.
...and there were no accompanying messages logged by syslog? In

None at all at both sides. (btw, I am running NFSv3)

Bye,
Oleg

#26 lore raw
In reply to Oleg Drokin

In article <[email protected]>,

Quoted 2 lines · Oleg Drokin

So we solved that with patch below (Zygo, others who think they have this problem, please check).

I am building a kernel with the patch as I type this. I'll know if it works in a few hours.

If it does work, I'll be running reiserfsck for the rest of the week to clean out all those dead direntries on all my systems once and for all. :-P

Reiserfsck takes 53 hours to scan everything on some of my machines, which is a long time considering that I already know where all the missing direntries are since they are recorded in various error log files.

I don't suppose it's a quick or easy task to modify reiserfsck to just fix _one_ missing directory entry, or to allow the kernel to unlink missing direntries instead of returning EPERM? Would it suffice to simply hack up the unlink() code so that the direntry is removed but the missing SD is ignored?

Signature · 2 lines
Zygo Blaxell (Laptop) <[email protected]>
GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
#27 lore raw
Quoted 9 lines · Zygo Blaxell

In article <[email protected]>,

Quoted 2 lines · Oleg Drokin

So we solved that with patch below (Zygo, others who think they have
this problem, please check).

I am building a kernel with the patch as I type this. I'll know if it works in a few hours.

Quoted 8 lines

If it does work, I'll be running reiserfsck for the rest of the week to clean out all those dead direntries on all my systems once and for all.

:-P

Reiserfsck takes 53 hours to scan everything on some of my machines, which is a long time considering that I already know where all the missing direntries are since they are recorded in various error log files.

which version of reiserfsprogs do you use? and is this in the rebuild-tree mode? if it is, 3.6.5-pre1 had a speedup for pass0.

Quoted 5 lines

I don't suppose it's a quick or easy task to modify reiserfsck to just fix _one_ missing directory entry, or to allow the kernel to unlink missing direntries instead of returning EPERM? Would it suffice to simply hack up the unlink() code so that the direntry is removed but the missing SD is ignored?

After figuring out what is the exact problem here I can answer if it is easy on not. I will respont probably tomorrow morning about it.

P.S. btw, I am going to release a new version of fsck which has some on-boot time checks. Is it possible to try it on your big partitions to fugure out if it takes less then a few seconds?

Signature · 2 lines
Thanks,
Vitaly Fertman
#28 lore raw

In article <[email protected]>,

Quoted 6 lines · Vitaly Fertman
Quoted 3 lines

Reiserfsck takes 53 hours to scan everything on some of my machines, which is a long time considering that I already know where all the missing direntries are since they are recorded in various error log files.

which version of reiserfsprogs do you use? and is this in the rebuild-tree mode? if it is, 3.6.5-pre1 had a speedup for pass0.

This is 3.6.5-pre1 in --fix-fixable mode. 600 GB of data, average file size 12K. It currently takes about 8-10 days to dump all of the data to tape.

Quoted 3 lines

P.S. btw, I am going to release a new version of fsck which has some on-boot time checks. Is it possible to try it on your big partitions to fugure out if it takes less then a few seconds?

I could probably fit in a few short tests.

Signature · 2 lines
Zygo Blaxell (Laptop) <[email protected]>
GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
#32 lore raw
In reply to Zygo Blaxell

Hello!

Quoted 7 lines · Zygo Blaxell
Quoted 2 lines

So we solved that with patch below (Zygo, others who think they have this problem, please check).

I am building a kernel with the patch as I type this. I'll know if it works in a few hours.
If it does work, I'll be running reiserfsck for the rest of the week to clean out all those dead direntries on all my systems once and for all. :-P

Actually I have different version that eventually will be pushed to Marcelo (iget5_locked backport). Unfortunatelly it is also touches NFS and Coda.
(and I am not yet sure for NFS changes, though they are working for me).

Quoted 1 line

Reiserfsck takes 53 hours to scan everything on some of my machines,

Wow.
You probably do not have spare filesystem to run reiserfsck with profiling compiled in for us, though.

Quoted 3 lines

I don't suppose it's a quick or easy task to modify reiserfsck to just fix _one_ missing directory entry, or to allow the kernel to unlink missing direntries instead of returning EPERM? Would it suffice to simply hack

Well, that is in fact may be easy. (but that would not be a kernel you want to run every day ;) ).
Also GNU rm checks file's mode prior to unlinking, I believe.
And that won;t get rid on lost file you might have, too.

Bye,
Oleg

#33 lore raw
Quoted 38 lines · Oleg Drokin

Hello!

Quoted 10 lines · Zygo Blaxell
Quoted 4 lines

So we solved that with patch below (Zygo, others who think they have this problem, please check).

I am building a kernel with the patch as I type this. I'll know if it works in a few hours. If it does work, I'll be running reiserfsck for the rest of the week to
clean out all those dead direntries on all my systems once and for all.
:-P

Actually I have different version that eventually will be pushed to Marcelo (iget5_locked backport). Unfortunatelly it is also touches NFS and Coda.
(and I am not yet sure for NFS changes, though they are working for me).

Quoted 3 lines

Reiserfsck takes 53 hours to scan everything on some of my machines,

Wow.
You probably do not have spare filesystem to run reiserfsck with profiling compiled in for us, though.

Quoted 5 lines

I don't suppose it's a quick or easy task to modify reiserfsck to just fix _one_ missing directory entry, or to allow the kernel to unlink missing direntries instead of returning EPERM? Would it suffice to simply hack

Quoted 11 lines

Well, that is in fact may be easy. (but that would not be a kernel you want to run every day ;) ).
Also GNU rm checks file's mode prior to unlinking, I believe.
And that won;t get rid on lost file you might have, too.

Bye,
Oleg

I am confused. What concrete solution are you emailing him?

Signature · 1 line
Hans
#34 lore raw

Hello!

Quoted 9 lines · Hans Reiser
Quoted 8 lines
Quoted 3 lines

I don't suppose it's a quick or easy task to modify reiserfsck to just fix _one_ missing directory entry, or to allow the kernel to unlink missing direntries instead of returning EPERM? Would it suffice to simply hack

Well, that is in fact may be easy. (but that would not be a kernel you want to run
every day ;) ).
Also GNU rm checks file's mode prior to unlinking, I believe. And that won;t get rid on lost file you might have, too.

I am confused. What concrete solution are you emailing him?

None. I am just speculating about adding possibility to remove "direntries pointing to nowhere" into kernel. I may be even do more research on this later, after I fix another directio bug (the one referenced by IBM guys).

Bye,
Oleg

#29 lore raw
In reply to Zygo Blaxell
Quoted 7 lines · Zygo Blaxell

In article <[email protected]>,

Quoted 4 lines · Vitaly Fertman
Quoted 4 lines

Reiserfsck takes 53 hours to scan everything on some of my machines, which is a long time considering that I already know where all the missing direntries are since they are recorded in various error log files.

Ok, I could try to remove them faster, if you give me the list of these directories - all those messages in logs, and an account on your computer.

Quoted 6 lines
Quoted 2 lines

which version of reiserfsprogs do you use? and is this in the rebuild-tree mode? if it is, 3.6.5-pre1 had a speedup for pass0.

This is 3.6.5-pre1 in --fix-fixable mode. 600 GB of data, average file size 12K. It currently takes about 8-10 days to dump all of the data to tape.

Hm, fix-fixable works faster usually. It would be not bad to get the metadata of this partition, and to profile it locally. Although, metadata dump will take some time also. If you have this time on one of your mashins, could you run debugreiserfs -p /dev/xxx | bzip2 -c > xxx.bz2

Quoted 5 lines
Quoted 3 lines

P.S. btw, I am going to release a new version of fsck which has some on-boot time checks. Is it possible to try it on your big partitions to fugure out if it takes less then a few seconds?

I could probably fit in a few short tests.

Signature · 2 lines
Thanks,
Vitaly Fertman
#30 lore raw

In article <[email protected]>,

Quoted 2 lines · Vitaly Fertman

Ok, I could try to remove them faster, if you give me the list of these directories - all those messages in logs, and an account on your computer.

Handing out access to this (proprietary) data is probably not worth saving 53 hours. I have pairs of fileservers set up as mirrors of each other. They're meant to survive one of the machines falling off the shelf and breaking all of its disks. In the best case nobody will notice the reiserfsck, and in the worst case I'll have to abort the reiserfsck and live with the dangling direntries for a few more days. Also, I need to schedule a test of the automatic failover this month anyway. ;-)

I was hoping for something along the lines of "if you turn off these parts of the kernel code, it will let unlink() work even if it can't find an inode." I'd then boot a kernel modified that way, delete all the offending files, then switch back to a regular kernel, which could all be done in a single day.

Quoted 1 line

Hm, fix-fixable works faster usually.

It does! You should see how long --rebuild-tree takes! ;-)

Quoted 4 lines

It would be not bad to get the metadata
of this partition, and to profile it locally. Although, metadata dump will take some time also. If you have this time on one of your mashins, could you run debugreiserfs -p /dev/xxx | bzip2 -c > xxx.bz2

I did that once many months ago. It ran out of space after 40 gigabytes of .bz2 output, and I never tried it again (and this was with the filesystem about 60% full...now it's 90% full). It looked like it had dumped about 30% of the tree data before it died.

Signature · 2 lines
Zygo Blaxell (Laptop) <[email protected]>
GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
#31 lore raw
Quoted 8 lines · Zygo Blaxell

In article <[email protected]>,

Quoted 2 lines · Vitaly Fertman

Ok, I could try to remove them faster, if you give me the list of these directories - all those messages in logs, and an account on your computer.

Handing out access to this (proprietary) data is probably not worth saving 53 hours. I have pairs of fileservers set up as mirrors of

well, it would be a fast hack, not tested properly, so I would prefere to control how it goes with debugger.

Quoted 12 lines

each other. They're meant to survive one of the machines falling off the shelf and breaking all of its disks. In the best case nobody will notice the reiserfsck, and in the worst case I'll have to abort the reiserfsck and live with the dangling direntries for a few more days. Also, I need to schedule a test of the automatic failover this month anyway. ;-)

I was hoping for something along the lines of "if you turn off these parts of the kernel code, it will let unlink() work even if it can't find an inode." I'd then boot a kernel modified that way, delete all the offending files, then switch back to a regular kernel, which could all be done in a single day.

Quoted 3 lines
Quoted 1 line

Hm, fix-fixable works faster usually.

It does! You should see how long --rebuild-tree takes! ;-)

there is one known bottleneck with objectid map on semantic rebuild pass and I will improve it as when I will have time on it. Other things should be profiled.

Quoted 9 lines
Quoted 4 lines

It would be not bad to get the metadata
of this partition, and to profile it locally. Although, metadata dump will take some time also. If you have this time on one of your mashins, could you run debugreiserfs -p /dev/xxx | bzip2 -c > xxx.bz2

I did that once many months ago. It ran out of space after 40 gigabytes of .bz2 output, and I never tried it again (and this was with the filesystem about 60% full...now it's 90% full). It looked like it had dumped about 30% of the tree data before it died.

oh, looks like you have only a few kilobytes files on it.

Signature · 2 lines
Thanks,
Vitaly Fertman
#35 lore raw
In reply to Oleg Drokin

In article <[email protected]>,

Quoted 2 lines · Oleg Drokin

So we solved that with patch below (Zygo, others who think they have this problem, please check).

...

fs/reiserfs/inode.c

Quoted 3 lines

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +0 -0

OK, I did the following:

patch kernel

install patched kernel

umount filesystem

reiserfsck 3.6.5-pre1 --fix-fixable the filesystem

forgot to note the last few things reiserfsck said

reboot machine

verify that patched kernel is running

wait a few days

read "unlink: Permission denied" in logs

I'm wondering if I'm still seeing the bug, or just the lingering after-effects of the bug that might still be hiding in the filesystem.

Is fix-fixable able to correct link counts? If not, presumably I need to do a full rebuild-tree in order to correct any incorrect link counts that may still be present on the filesystem?

Signature · 2 lines
Zygo Blaxell (Laptop) <[email protected]>
GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
#36 lore raw

Hello!

Quoted 6 lines · Zygo Blaxell

OK, I did the following:
patch kernel
install patched kernel
umount filesystem
reiserfsck 3.6.5-pre1 --fix-fixable the filesystem forgot to note the last few things reiserfsck said

Ideally, resiserfsck should have told you wwhenever there were any unfixed corruptions left.

Quoted 6 lines

reboot machine
verify that patched kernel is running
wait a few days
read "unlink: Permission denied" in logs
I'm wondering if I'm still seeing the bug, or just the lingering after-effects of the bug that might still be hiding in the filesystem.

Hard to tell. But it well might be a hiding bugs. --fix-fixable does not correct link counts, so if you have file with nlinks=3 and 4 hardlinks to it, you are in trouble after three of the hardlinks are removed.

Quoted 1 line

Is fix-fixable able to correct link counts? If not, presumably I need

No. It may only delete entries pointing to nowhere, I think.

Quoted 2 lines

to do a full rebuild-tree in order to correct any incorrect link counts that may still be present on the filesystem?

Probably yes.

Bye,
Oleg

#15 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

In reply to Jan Harkes

Hello!

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

Patch is below for your reference. Thank you.

Bye,
Oleg
===== Documentation/filesystems/Locking 1.7 vs edited =====

Documentation/filesystems/Locking +1 -1
@@ -114,7 +114,7 @@
 remount_fs:	yes	yes	maybe		(see below)
 umount_begin:	yes	no	maybe		(see below)
 
-->read_inode() is not a method - it's a callback used in iget()/iget4().
+->read_inode() is not a method - it's a callback used in iget().
 rules for mount_sem are not too nice - it is going to die and be replaced
 by better scheme anyway.
 

===== fs/Makefile 1.16 vs edited =====

fs/Makefile +1 -1
@@ -7,7 +7,7 @@
 
 O_TARGET := fs.o
 
-export-objs :=	filesystems.o open.o dcache.o buffer.o
+export-objs :=	filesystems.o open.o dcache.o buffer.o inode.o
 mod-subdirs :=	nls
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \

===== fs/inode.c 1.36 vs edited =====

fs/inode.c +148 -38

271 lines not on this page · raw message

===== fs/coda/cnode.c 1.8 vs edited =====

fs/coda/cnode.c +41 -47

151 lines not on this page · raw message

===== fs/coda/inode.c 1.9 vs edited =====

fs/coda/inode.c +0 -20
@@ -34,7 +34,6 @@
 
 /* VFS super_block ops */
 static struct super_block *coda_read_super(struct super_block *, void *, int);
-static void coda_read_inode(struct inode *);
 static void coda_clear_inode(struct inode *);
 static void coda_put_super(struct super_block *);
 static int coda_statfs(struct super_block *sb, struct statfs *buf);
@@ -42,7 +41,6 @@
 /* exported operations */
 struct super_operations coda_super_operations =
 {
-	read_inode:	coda_read_inode,
 	clear_inode:	coda_clear_inode,
 	put_super:	coda_put_super,
 	statfs:		coda_statfs,
@@ -179,24 +177,6 @@
 
 	printk("Coda: Bye bye.\n");
 	kfree(sbi);
-}
-
-/* all filling in of inodes postponed until lookup */
-static void coda_read_inode(struct inode *inode)
-{
-	struct coda_sb_info *sbi = coda_sbp(inode->i_sb);
-	struct coda_inode_info *cii;
-
-        if (!sbi) BUG();
-
-	cii = ITOC(inode);
-	if (!coda_isnullfid(&cii->c_fid)) {
-            printk("coda_read_inode: initialized inode");
-            return;
-        }
-
-	cii->c_mapcount = 0;
-	list_add(&cii->c_cilist, &sbi->sbi_cihead);
 }
 
 static void coda_clear_inode(struct inode *inode)

===== fs/nfs/inode.c 1.18 vs edited =====

fs/nfs/inode.c +34 -34

126 lines not on this page · raw message

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +29 -27

122 lines not on this page · raw message

===== fs/reiserfs/super.c 1.27 vs edited =====

fs/reiserfs/super.c +9 -5
@@ -381,8 +381,6 @@
 
 struct super_operations reiserfs_sops = 
 {
-  read_inode: reiserfs_read_inode,
-  read_inode2: reiserfs_read_inode2,
   write_inode: reiserfs_write_inode,
   dirty_inode: reiserfs_dirty_inode,
   delete_inode: reiserfs_delete_inode,
@@ -1117,7 +1115,7 @@
     int old_format = 0;
     unsigned long blocks;
     int jinit_done = 0 ;
-    struct reiserfs_iget4_args args ;
+    struct reiserfs_iget_args args ;
     int old_magic;
     struct reiserfs_super_block * rs;
 
@@ -1194,11 +1192,17 @@
         printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
 	s->s_flags |= MS_RDONLY ;
     }
-    args.objectid = REISERFS_ROOT_PARENT_OBJECTID ;
-    root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args));
+    args.objectid = REISERFS_ROOT_OBJECTID ;
+    args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
+    root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
     if (!root_inode) {
 	printk ("reiserfs_read_super: get root inode failed\n");
 	goto error;
+    }
+ 
+    if (root_inode->i_state & I_NEW) {
+	reiserfs_read_locked_inode(root_inode, &args);
+	unlock_new_inode(root_inode);
     }
 
     s->s_root = d_alloc_root(root_inode);  

===== include/linux/fs.h 1.74 vs edited =====

include/linux/fs.h +18 -11
@@ -885,13 +885,6 @@
 
 	void (*read_inode) (struct inode *);
   
-  	/* reiserfs kludge.  reiserfs needs 64 bits of information to
-    	** find an inode.  We are using the read_inode2 call to get
-   	** that information.  We don't like this, and are waiting on some
-   	** VFS changes for the real solution.
-   	** iget4 calls read_inode2, iff it is defined
-   	*/
-    	void (*read_inode2) (struct inode *, void *) ;
    	void (*dirty_inode) (struct inode *);
 	void (*write_inode) (struct inode *, int);
 	void (*put_inode) (struct inode *);
@@ -940,6 +933,7 @@
 #define I_LOCK			8
 #define I_FREEING		16
 #define I_CLEAR			32
+#define I_NEW			64
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 
@@ -1378,19 +1372,32 @@
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 
-typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
-extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
+extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+extern void unlock_new_inode(struct inode *);
+
 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
 {
-	return iget4(sb, ino, NULL, NULL);
+	struct inode *inode = iget_locked(sb, ino);
+
+	if (inode && (inode->i_state & I_NEW)) {
+		sb->s_op->read_inode(inode);
+		unlock_new_inode(inode);
+	}
+
+	return inode;
 }
 
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *sb);
 extern void remove_suid(struct inode *inode);
 
-extern void insert_inode_hash(struct inode *);
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+	__insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern struct buffer_head * get_hash_table(kdev_t, int, int);

===== include/linux/reiserfs_fs.h 1.26 vs edited =====

include/linux/reiserfs_fs.h +5 -3
@@ -1478,8 +1478,9 @@
 #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
 #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
 
-struct reiserfs_iget4_args {
+struct reiserfs_iget_args {
     __u32 objectid ;
+    __u32 dirid ;
 } ;
 
 /***************************************************************************/
@@ -1730,8 +1731,9 @@
 
 /* inode.c */
 
-void reiserfs_read_inode (struct inode * inode) ;
-void reiserfs_read_inode2(struct inode * inode, void *p) ;
+void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
+int reiserfs_find_actor(struct inode * inode, void *p) ;
+int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
 void reiserfs_delete_inode (struct inode * inode);
 void reiserfs_write_inode (struct inode * inode, int) ;
 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data,

===== kernel/ksyms.c 1.67 vs edited =====

kernel/ksyms.c +1 -2
@@ -140,7 +140,6 @@
 EXPORT_SYMBOL(fget);
 EXPORT_SYMBOL(igrab);
 EXPORT_SYMBOL(iunique);
-EXPORT_SYMBOL(iget4);
 EXPORT_SYMBOL(iput);
 EXPORT_SYMBOL(inode_init_once);
 EXPORT_SYMBOL(force_delete);
@@ -528,7 +527,7 @@
 EXPORT_SYMBOL(read_ahead);
 EXPORT_SYMBOL(get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);
#16 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Quoted 5 lines · Oleg Drokin

Hello!

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

#17 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Quoted 9 lines · Alan Cox
Quoted 5 lines · Oleg Drokin

Hello!

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

In 2.4 there is a race when find_actor is used in conjunction with ->read_inode2, because inode_lock is released before calling ->read_inode2 and hence, find_actor cannot safely rely on initialisations of inode's private part done in ->read_inode2. This is why in 2.5 iget5_locked takes special "set" callback that is called from under inode_lock. It so happened that reiserfs is the only (is it?) file system that used both find_actor and ->read_inode2, but whole API is just broken and should be fixed.

Quoted 1 line

Nikita.

#18 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

In reply to Alan Cox

Hello!

Quoted 5 lines · Alan Cox
Quoted 3 lines

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already. Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

Bye,
Oleg

#19 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Quoted 4 lines · Oleg Drokin
Quoted 3 lines · Alan Cox
Quoted 3 lines

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

Quoted 8 lines
Quoted 2 lines

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already. Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

I agree it should go into 2.4 but I don't think the patches you are submitting should go in. From what I can see they are an older version compared to what actually went into 2.5. (I am basing this on the comments to the functions rather than thorough code comparisons but I don't have time to look at it more in depth atm.) Why don't you use the actual 2.5 code and make new patches or at least make use of the patches that finally went into 2.5?

Best regards,

Anton

Signature · 3 lines
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
#20 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Hello!

Quoted 5 lines · Anton Altaparmakov
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

Quoted 8 lines
Quoted 5 lines

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already. Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

I agree it should go into 2.4 but I don't think the patches you are submitting should go in. From what I can see they are an older version compared to what actually went into 2.5. (I am basing this on the comments

What I am submitting is just changesets 1.373.172.1..1.373.172.6 from 2.5 bk tree. So these patches are what went into 2.5 (plus all the bugs I have made during adapting these to 2.4, of course).

Quoted 4 lines

to the functions rather than thorough code comparisons but I don't have time to look at it more in depth atm.) Why don't you use the actual 2.5 code and make new patches or at least make use of the patches that finally went into 2.5?

Looking at the changelog, it seems much later on there were ifind_fast() and ifind() additions to this code, but I was not sure I should take these too.
I can though, if people think that would be useful.

Bye,
Oleg

#21 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Quoted 11 lines · Oleg Drokin
Quoted 10 lines · Anton Altaparmakov
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already. Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

Quoted 7 lines
Quoted 3 lines

I agree it should go into 2.4 but I don't think the patches you are submitting should go in. From what I can see they are an older version compared to what actually went into 2.5. (I am basing this on the comments

What I am submitting is just changesets 1.373.172.1..1.373.172.6 from 2.5 bk tree. So these patches are what went into 2.5 (plus all the bugs I have made during adapting these to 2.4, of course).

That's ok then.

Quoted 8 lines
Quoted 4 lines

to the functions rather than thorough code comparisons but I don't have time to look at it more in depth atm.) Why don't you use the actual 2.5 code and make new patches or at least make use of the patches that finally went into 2.5?

Looking at the changelog, it seems much later on there were ifind_fast() and ifind() additions to this code, but I was not sure I should take these too.
I can though, if people think that would be useful.

Up to you. Would be nice to have both. The code with the ifind() and ilookup() functions has existed for longer I think so if your argument is that the code has been tested in 2.5 already so can go in 2.4 then taking that is probably better to take these, too.

Best regards,

Anton

Signature · 3 lines
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
#22 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Hello!

Quoted 11 lines · Anton Altaparmakov
Quoted 7 lines
Quoted 4 lines

to the functions rather than thorough code comparisons but I don't have time to look at it more in depth atm.) Why don't you use the actual 2.5 code and make new patches or at least make use of the patches that finally went into 2.5?

Looking at the changelog, it seems much later on there were ifind_fast() and ifind() additions to this code, but I was not sure I should take these too.
I can though, if people think that would be useful.

Up to you. Would be nice to have both. The code with the ifind() and ilookup() functions has existed for longer I think so if your argument is that the code has been tested in 2.5 already so can go in 2.4 then taking that is probably better to take these, too.

Well, two patches from you that implement these (merged into 2.5 as of September 18th, 2002) applied cleanly to previously posted patch ;) And the result even compiled.
Resulting diff is below.

Bye,
Oleg

===== Documentation/filesystems/Locking 1.7 vs edited =====

Documentation/filesystems/Locking +1 -1
@@ -114,7 +114,7 @@
 remount_fs:	yes	yes	maybe		(see below)
 umount_begin:	yes	no	maybe		(see below)
 
-->read_inode() is not a method - it's a callback used in iget()/iget4().
+->read_inode() is not a method - it's a callback used in iget().
 rules for mount_sem are not too nice - it is going to die and be replaced
 by better scheme anyway.
 

===== fs/Makefile 1.16 vs edited =====

fs/Makefile +1 -1
@@ -7,7 +7,7 @@
 
 O_TARGET := fs.o
 
-export-objs :=	filesystems.o open.o dcache.o buffer.o
+export-objs :=	filesystems.o open.o dcache.o buffer.o inode.o
 mod-subdirs :=	nls
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \

===== fs/inode.c 1.36 vs edited =====

fs/inode.c +279 -39

414 lines not on this page · raw message

===== fs/coda/cnode.c 1.8 vs edited =====

fs/coda/cnode.c +41 -47

151 lines not on this page · raw message

===== fs/coda/inode.c 1.9 vs edited =====

fs/coda/inode.c +0 -20
@@ -34,7 +34,6 @@
 
 /* VFS super_block ops */
 static struct super_block *coda_read_super(struct super_block *, void *, int);
-static void coda_read_inode(struct inode *);
 static void coda_clear_inode(struct inode *);
 static void coda_put_super(struct super_block *);
 static int coda_statfs(struct super_block *sb, struct statfs *buf);
@@ -42,7 +41,6 @@
 /* exported operations */
 struct super_operations coda_super_operations =
 {
-	read_inode:	coda_read_inode,
 	clear_inode:	coda_clear_inode,
 	put_super:	coda_put_super,
 	statfs:		coda_statfs,
@@ -179,24 +177,6 @@
 
 	printk("Coda: Bye bye.\n");
 	kfree(sbi);
-}
-
-/* all filling in of inodes postponed until lookup */
-static void coda_read_inode(struct inode *inode)
-{
-	struct coda_sb_info *sbi = coda_sbp(inode->i_sb);
-	struct coda_inode_info *cii;
-
-        if (!sbi) BUG();
-
-	cii = ITOC(inode);
-	if (!coda_isnullfid(&cii->c_fid)) {
-            printk("coda_read_inode: initialized inode");
-            return;
-        }
-
-	cii->c_mapcount = 0;
-	list_add(&cii->c_cilist, &sbi->sbi_cihead);
 }
 
 static void coda_clear_inode(struct inode *inode)

===== fs/nfs/inode.c 1.18 vs edited =====

fs/nfs/inode.c +34 -34

126 lines not on this page · raw message

===== fs/reiserfs/inode.c 1.42 vs edited =====

fs/reiserfs/inode.c +29 -27

122 lines not on this page · raw message

===== fs/reiserfs/super.c 1.27 vs edited =====

fs/reiserfs/super.c +9 -5
@@ -381,8 +381,6 @@
 
 struct super_operations reiserfs_sops = 
 {
-  read_inode: reiserfs_read_inode,
-  read_inode2: reiserfs_read_inode2,
   write_inode: reiserfs_write_inode,
   dirty_inode: reiserfs_dirty_inode,
   delete_inode: reiserfs_delete_inode,
@@ -1117,7 +1115,7 @@
     int old_format = 0;
     unsigned long blocks;
     int jinit_done = 0 ;
-    struct reiserfs_iget4_args args ;
+    struct reiserfs_iget_args args ;
     int old_magic;
     struct reiserfs_super_block * rs;
 
@@ -1194,11 +1192,17 @@
         printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
 	s->s_flags |= MS_RDONLY ;
     }
-    args.objectid = REISERFS_ROOT_PARENT_OBJECTID ;
-    root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args));
+    args.objectid = REISERFS_ROOT_OBJECTID ;
+    args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
+    root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
     if (!root_inode) {
 	printk ("reiserfs_read_super: get root inode failed\n");
 	goto error;
+    }
+ 
+    if (root_inode->i_state & I_NEW) {
+	reiserfs_read_locked_inode(root_inode, &args);
+	unlock_new_inode(root_inode);
     }
 
     s->s_root = d_alloc_root(root_inode);  

===== include/linux/fs.h 1.74 vs edited =====

include/linux/fs.h +22 -11
@@ -885,13 +885,6 @@
 
 	void (*read_inode) (struct inode *);
   
-  	/* reiserfs kludge.  reiserfs needs 64 bits of information to
-    	** find an inode.  We are using the read_inode2 call to get
-   	** that information.  We don't like this, and are waiting on some
-   	** VFS changes for the real solution.
-   	** iget4 calls read_inode2, iff it is defined
-   	*/
-    	void (*read_inode2) (struct inode *, void *) ;
    	void (*dirty_inode) (struct inode *);
 	void (*write_inode) (struct inode *, int);
 	void (*put_inode) (struct inode *);
@@ -940,6 +933,7 @@
 #define I_LOCK			8
 #define I_FREEING		16
 #define I_CLEAR			32
+#define I_NEW			64
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 
@@ -1378,19 +1372,36 @@
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 
-typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
-extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
+extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
+		int (*test)(struct inode *, void *), void *data);
+extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
+
+extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+extern void unlock_new_inode(struct inode *);
+
 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
 {
-	return iget4(sb, ino, NULL, NULL);
+	struct inode *inode = iget_locked(sb, ino);
+
+	if (inode && (inode->i_state & I_NEW)) {
+		sb->s_op->read_inode(inode);
+		unlock_new_inode(inode);
+	}
+
+	return inode;
 }
 
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *sb);
 extern void remove_suid(struct inode *inode);
 
-extern void insert_inode_hash(struct inode *);
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+	__insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern struct buffer_head * get_hash_table(kdev_t, int, int);

===== include/linux/reiserfs_fs.h 1.26 vs edited =====

include/linux/reiserfs_fs.h +5 -3
@@ -1478,8 +1478,9 @@
 #define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))
 #define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
 
-struct reiserfs_iget4_args {
+struct reiserfs_iget_args {
     __u32 objectid ;
+    __u32 dirid ;
 } ;
 
 /***************************************************************************/
@@ -1730,8 +1731,9 @@
 
 /* inode.c */
 
-void reiserfs_read_inode (struct inode * inode) ;
-void reiserfs_read_inode2(struct inode * inode, void *p) ;
+void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
+int reiserfs_find_actor(struct inode * inode, void *p) ;
+int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
 void reiserfs_delete_inode (struct inode * inode);
 void reiserfs_write_inode (struct inode * inode, int) ;
 struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, __u32 *data,

===== kernel/ksyms.c 1.67 vs edited =====

kernel/ksyms.c +1 -2
@@ -140,7 +140,6 @@
 EXPORT_SYMBOL(fget);
 EXPORT_SYMBOL(igrab);
 EXPORT_SYMBOL(iunique);
-EXPORT_SYMBOL(iget4);
 EXPORT_SYMBOL(iput);
 EXPORT_SYMBOL(inode_init_once);
 EXPORT_SYMBOL(force_delete);
@@ -528,7 +527,7 @@
 EXPORT_SYMBOL(read_ahead);
 EXPORT_SYMBOL(get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);
maintainer
#23 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

In reply to Oleg Drokin
Quoted 6 lines · Oleg Drokin

Hello!

Quoted 3 lines · Alan Cox
Quoted 3 lines

It's me again, I basically got no reply for this iget5_locked patch I have now. Would there be any objections if I try push it to Marcelo tomorrow? ;)

Quoted 7 lines
Quoted 2 lines

I just binned it. Certainly its not the kind of stuff I want to test in -ac, too many VFS changes outside reiserfs

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already.

It is simple enough, and it does fixe real bug. However at the time it was decided that the change should not go into 2.4 because it breaks the VFS API for 3rd party filesystems. Basically anyone that might be using iget4 and/or read_inode2 will have to change their filesystem in the middle of a supposedly stable series.

I believe that argument still stands. Ofcourse anyone using the existing iget4/read_inode[2] interface is pretty much guaranteed to have broken code.

Quoted 2 lines

Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

Yeah, I actually hit that bug while working on Coda which prompted the whole iget5_locked implementation. The fix I used for 2.4 is trivial but inefficient. Just grab a lock around any call to iget4. I think I used a semaphore as I wasn't sure whether the iget4 code would sleep.

Jan

#24 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

Hello!

Quoted 9 lines · Jan Harkes
Quoted 4 lines

Andrew Morton said "iget5_locked() looks simple enough, and as far as I can tell does not change any existing code - it just adds new stuff.", also this code (in its 2.5 incarnation) was tested in 2.5 for long time already.

It is simple enough, and it does fixe real bug. However at the time it was decided that the change should not go into 2.4 because it breaks the VFS API for 3rd party filesystems. Basically anyone that might be using iget4 and/or read_inode2 will have to change their filesystem in the middle of a supposedly stable series.

That argument never worked in case that change was imposed by fixing a bug.

Quoted 3 lines

I believe that argument still stands. Ofcourse anyone using the existing iget4/read_inode[2] interface is pretty much guaranteed to have broken code.

Yes, and this is the problem, I think.

Quoted 4 lines
Quoted 2 lines

Also it fixes real bug (and while I have another reiserfs-only fix for the bug, it is fairly inelegant).

Yeah, I actually hit that bug while working on Coda which prompted the whole iget5_locked implementation. The fix I used for 2.4 is trivial but

And we hit this same bug too, recently (took quite a while to find out what's going on and why do we suddenly have directory entries pointing to nowhere and lost files).

Quoted 2 lines

inefficient. Just grab a lock around any call to iget4. I think I used a semaphore as I wasn't sure whether the iget4 code would sleep.

This is inefficient, as you have noticed already ;)

Bye,
Oleg

maintainer
#25 lore raw

Re: 2.4 iget5_locked port attempt to 2.4

In reply to Jan Harkes
Quoted 2 lines · Jan Harkes

Yeah, I actually hit that bug while working on Coda which prompted the whole iget5_locked implementation.

Hmm, I seem to be misrepresenting my role with this statement.

Yes, I found the bug in Coda, but the actual iget5_locked implementation was largely based on the icreate patches from XFS that were sent to me by Steve Lord.

There was a whole discussion on linux-fsdevel where Alexander Viro, Anton Altaparmakov, Steve Lord, Christoph Hellwig, Chris Mason, and probably others which I forgot all gave input and comments which I merged into the patches before they were submitted to Linus.

Just to give credit where credit is due.

Jan