Re: [NFS] Re: [RFC] yet another knfsd-reiserfs patch

2001-06-02 Thread Chris Mason



On Saturday, June 02, 2001 12:19:59 AM +0200 Trond Myklebust
<[EMAIL PROTECTED]> wrote:

> 
> Hi Chris,
> 
> Do you really need the parent inode in the filehandle?
> 
> That screws rename up pretty badly, since the filehandle changes when
> you rename into a different directory. It means for instance that when
> I do
> 
> open(foo)
> mv foo bar/
> write (foo)
> close(foo)
> 
> then I have a pretty good chance of getting an ESTALE on the write()
> statement.
> 

Hmmm, didn't realize I had only answered this in private mail.

The patch doesn't change when the parent dir's ino is included in the
filehandle, it just adds wrappers for storing it and getting it out.

For ext2, the parent inum is only sent for files when the subtree checks
are turned on (_fh_update is unchanged if no fill_fh func is provided).  

The reiserfs one always puts the parent inum into the fh, but
find_fh_dentry only pulls it out for directories or subtree checks so I
didn't add the extra logic to the reiserfs fill_fh func.

-chris

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [RFC] yet another knfsd-reiserfs patch

2001-06-02 Thread Hans Reiser

Why are people afraid to put Neil Brown's code into 2.4?  It works, we have tons
of users using it, it is the only nfs solution that has a tested reiserfs user
base, don't worry that it isn't tested and shouldn't go into 2.4 because it is
better tested than any of these quick fixes that are floated by people afraid of
Neil's code am I missing something?

Hans

Chris Mason wrote:
> 
> > On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason <[EMAIL PROTECTED]> wrote:
> >
> >>
> >> Hi guys,
> >>
> >> This patch is not meant to replace Neil Brown's knfsd ops stuff, the
> >> goal was to whip up something that had a chance of getting into 2.4.x,
> >> and that might be usable by the AFS guys too.  Neil's patch tries to
> >> address a bunch of things that I didn't, and looks better for the
> >> long run.
> >>
> >
> 
> Updated to 2.4.5, with the nfs list cc'd this time in hopes of comments
> or flames...
> 
> -chris
> 
> diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
> --- a/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
> +++ b/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
> @@ -116,40 +116,12 @@
> return error;
>  }
> 
> -/* this should be provided by each filesystem in an nfsd_operations interface as
> - * iget isn't really the right interface
> - */
> -static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
>generation)
> +static struct dentry *dentry_from_inode(struct inode *inode)
>  {
> -
> -   /* iget isn't really right if the inode is currently unallocated!!
> -* This should really all be done inside each filesystem
> -*
> -* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
> -*   had been deleted.
> -*
> -* Currently we don't know the generation for parent directory, so a 
>generation
> -* of 0 means "accept any"
> -*/
> -   struct inode *inode;
> struct list_head *lp;
> struct dentry *result;
> -   inode = iget(sb, ino);
> -   if (is_bad_inode(inode)
> -   || (generation && inode->i_generation != generation)
> -   ) {
> -   /* we didn't find the right inode.. */
> -   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
> -   inode->i_ino,
> -   inode->i_nlink, atomic_read(>i_count),
> -   inode->i_generation,
> -   generation);
> -
> -   iput(inode);
> -   return ERR_PTR(-ESTALE);
> -   }
> -   /* now to find a dentry.
> -* If possible, get a well-connected one
> +   /*
> +* If possible, get a well-connected dentry
>  */
> spin_lock(_lock);
> for (lp = inode->i_dentry.next; lp != >i_dentry ; lp=lp->next) {
> @@ -173,6 +145,92 @@
> return result;
>  }
> 
> +static struct inode *__inode_from_fh(struct super_block *sb, int ino,
> +int generation)
> +{
> +   struct inode *inode ;
> +
> +   inode = iget(sb, ino);
> +   if (is_bad_inode(inode)
> +   || (generation && inode->i_generation != generation)
> +   ) {
> +   /* we didn't find the right inode.. */
> +   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
> +   inode->i_ino,
> +   inode->i_nlink, atomic_read(>i_count),
> +   inode->i_generation,
> +   generation);
> +
> +   iput(inode);
> +   return ERR_PTR(-ESTALE);
> +   }
> +   return inode ;
> +}
> +
> +static struct inode *inode_from_fh(struct super_block *sb,
> +   __u32 *datap,
> +   int len)
> +{
> +   if (sb->s_op->inode_from_fh)
> +   return sb->s_op->inode_from_fh(sb, datap, len) ;
> +   return __inode_from_fh(sb, datap[0], datap[1]) ;
> +}
> +
> +static struct inode *parent_from_fh(struct super_block *sb,
> +   __u32 *datap,
> +   int len)
> +{
> +   if (sb->s_op->parent_from_fh)
> +   return sb->s_op->parent_from_fh(sb, datap, len) ;
> +
> +   if (len >= 3)
> +   return __inode_from_fh(sb, datap[2], 0) ;
> +   return ERR_PTR(-ESTALE);
> +}
> +
> +/*
> + * two iget funcs, one for inode, and one for parent directory
> + *
> + * this should be provided by each filesystem in an nfsd_operations interface as
> + * iget isn't really the right interface
> + *
> + * If the filesystem doesn't provide funcs to get inodes from datap,
> + * it must be: inum, generation, dir inum.  Length of 2 means the
> + * dir inum isn't there.
> + *
> + * iget isn't really right if the inode is currently unallocated!!
> + * This should really all be done inside each filesystem
> + *
> + * ext2fs' 

Re: [RFC] yet another knfsd-reiserfs patch

2001-06-02 Thread Hans Reiser

Why are people afraid to put Neil Brown's code into 2.4?  It works, we have tons
of users using it, it is the only nfs solution that has a tested reiserfs user
base, don't worry that it isn't tested and shouldn't go into 2.4 because it is
better tested than any of these quick fixes that are floated by people afraid of
Neil's code am I missing something?

Hans

Chris Mason wrote:
 
  On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason [EMAIL PROTECTED] wrote:
 
 
  Hi guys,
 
  This patch is not meant to replace Neil Brown's knfsd ops stuff, the
  goal was to whip up something that had a chance of getting into 2.4.x,
  and that might be usable by the AFS guys too.  Neil's patch tries to
  address a bunch of things that I didn't, and looks better for the
  long run.
 
 
 
 Updated to 2.4.5, with the nfs list cc'd this time in hopes of comments
 or flames...
 
 -chris
 
 diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
 --- a/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
 +++ b/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
 @@ -116,40 +116,12 @@
 return error;
  }
 
 -/* this should be provided by each filesystem in an nfsd_operations interface as
 - * iget isn't really the right interface
 - */
 -static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
 +static struct dentry *dentry_from_inode(struct inode *inode)
  {
 -
 -   /* iget isn't really right if the inode is currently unallocated!!
 -* This should really all be done inside each filesystem
 -*
 -* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
 -*   had been deleted.
 -*
 -* Currently we don't know the generation for parent directory, so a 
generation
 -* of 0 means accept any
 -*/
 -   struct inode *inode;
 struct list_head *lp;
 struct dentry *result;
 -   inode = iget(sb, ino);
 -   if (is_bad_inode(inode)
 -   || (generation  inode-i_generation != generation)
 -   ) {
 -   /* we didn't find the right inode.. */
 -   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
 -   inode-i_ino,
 -   inode-i_nlink, atomic_read(inode-i_count),
 -   inode-i_generation,
 -   generation);
 -
 -   iput(inode);
 -   return ERR_PTR(-ESTALE);
 -   }
 -   /* now to find a dentry.
 -* If possible, get a well-connected one
 +   /*
 +* If possible, get a well-connected dentry
  */
 spin_lock(dcache_lock);
 for (lp = inode-i_dentry.next; lp != inode-i_dentry ; lp=lp-next) {
 @@ -173,6 +145,92 @@
 return result;
  }
 
 +static struct inode *__inode_from_fh(struct super_block *sb, int ino,
 +int generation)
 +{
 +   struct inode *inode ;
 +
 +   inode = iget(sb, ino);
 +   if (is_bad_inode(inode)
 +   || (generation  inode-i_generation != generation)
 +   ) {
 +   /* we didn't find the right inode.. */
 +   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
 +   inode-i_ino,
 +   inode-i_nlink, atomic_read(inode-i_count),
 +   inode-i_generation,
 +   generation);
 +
 +   iput(inode);
 +   return ERR_PTR(-ESTALE);
 +   }
 +   return inode ;
 +}
 +
 +static struct inode *inode_from_fh(struct super_block *sb,
 +   __u32 *datap,
 +   int len)
 +{
 +   if (sb-s_op-inode_from_fh)
 +   return sb-s_op-inode_from_fh(sb, datap, len) ;
 +   return __inode_from_fh(sb, datap[0], datap[1]) ;
 +}
 +
 +static struct inode *parent_from_fh(struct super_block *sb,
 +   __u32 *datap,
 +   int len)
 +{
 +   if (sb-s_op-parent_from_fh)
 +   return sb-s_op-parent_from_fh(sb, datap, len) ;
 +
 +   if (len = 3)
 +   return __inode_from_fh(sb, datap[2], 0) ;
 +   return ERR_PTR(-ESTALE);
 +}
 +
 +/*
 + * two iget funcs, one for inode, and one for parent directory
 + *
 + * this should be provided by each filesystem in an nfsd_operations interface as
 + * iget isn't really the right interface
 + *
 + * If the filesystem doesn't provide funcs to get inodes from datap,
 + * it must be: inum, generation, dir inum.  Length of 2 means the
 + * dir inum isn't there.
 + *
 + * iget isn't really right if the inode is currently unallocated!!
 + * This should really all be done inside each filesystem
 + *
 + * ext2fs' read_inode has been strengthed to return a bad_inode if the inode
 + *   had been deleted.
 + *
 + * Currently we don't know the generation for parent directory, 

Re: [NFS] Re: [RFC] yet another knfsd-reiserfs patch

2001-06-02 Thread Chris Mason



On Saturday, June 02, 2001 12:19:59 AM +0200 Trond Myklebust
[EMAIL PROTECTED] wrote:

 
 Hi Chris,
 
 Do you really need the parent inode in the filehandle?
 
 That screws rename up pretty badly, since the filehandle changes when
 you rename into a different directory. It means for instance that when
 I do
 
 open(foo)
 mv foo bar/
 write (foo)
 close(foo)
 
 then I have a pretty good chance of getting an ESTALE on the write()
 statement.
 

Hmmm, didn't realize I had only answered this in private mail.

The patch doesn't change when the parent dir's ino is included in the
filehandle, it just adds wrappers for storing it and getting it out.

For ext2, the parent inum is only sent for files when the subtree checks
are turned on (_fh_update is unchanged if no fill_fh func is provided).  

The reiserfs one always puts the parent inum into the fh, but
find_fh_dentry only pulls it out for directories or subtree checks so I
didn't add the extra logic to the reiserfs fill_fh func.

-chris

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [NFS] Re: [RFC] yet another knfsd-reiserfs patch

2001-06-01 Thread Trond Myklebust


Hi Chris,

Do you really need the parent inode in the filehandle?

That screws rename up pretty badly, since the filehandle changes when
you rename into a different directory. It means for instance that when
I do

open(foo)
mv foo bar/
write (foo)
close(foo)

then I have a pretty good chance of getting an ESTALE on the write()
statement.

Cheers,
  Trond
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [RFC] yet another knfsd-reiserfs patch

2001-06-01 Thread Chris Mason


> On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason <[EMAIL PROTECTED]> wrote:
> 
>> 
>> Hi guys,
>> 
>> This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
>> goal was to whip up something that had a chance of getting into 2.4.x,
>> and that might be usable by the AFS guys too.  Neil's patch tries to 
>> address a bunch of things that I didn't, and looks better for the
>> long run.
>> 
> 

Updated to 2.4.5, with the nfs list cc'd this time in hopes of comments
or flames...

-chris

diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
+++ b/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means "accept any"
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation && inode->i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
-   inode->i_ino,
-   inode->i_nlink, atomic_read(>i_count),
-   inode->i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(_lock);
for (lp = inode->i_dentry.next; lp != >i_dentry ; lp=lp->next) {
@@ -173,6 +145,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation && inode->i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
+   inode->i_ino,
+   inode->i_nlink, atomic_read(>i_count),
+   inode->i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb->s_op->inode_from_fh)
+   return sb->s_op->inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb->s_op->parent_from_fh)
+   return sb->s_op->parent_from_fh(sb, datap, len) ;
+
+   if (len >= 3)
+   return __inode_from_fh(sb, datap[2], 0) ;
+   return ERR_PTR(-ESTALE);
+}
+
+/* 
+ * two iget funcs, one for inode, and one for parent directory
+ *
+ * this should be provided by each filesystem in an nfsd_operations interface as
+ * iget isn't really the right interface
+ *
+ * If the filesystem doesn't provide funcs to get inodes from datap,
+ * it must be: inum, generation, dir inum.  Length of 2 means the 
+ * dir inum isn't there.
+ *
+ * iget isn't really right if the inode is currently unallocated!!
+ * This should really all be done inside each filesystem
+ *
+ * ext2fs' read_inode has been strengthed to return a bad_inode if the inode
+ *   had been deleted.
+ *
+ * Currently we don't know the generation for parent directory, so a generation
+ * of 0 means "accept any"
+ */
+static struct dentry *nfsd_iget(struct super_block *sb, __u32 *datap, int len)
+{
+
+   struct inode *inode;
+
+   inode = inode_from_fh(sb, datap, len) ;
+   if (IS_ERR(inode)) {
+   return ERR_PTR(PTR_ERR(inode)) ;
+   }   
+   return dentry_from_inode(inode) ;
+}
+
+static struct dentry *nfsd_parent_iget(struct super_block *sb, __u32 *datap, 
+

Re: [RFC] yet another knfsd-reiserfs patch

2001-06-01 Thread Chris Mason


 On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason [EMAIL PROTECTED] wrote:
 
 
 Hi guys,
 
 This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
 goal was to whip up something that had a chance of getting into 2.4.x,
 and that might be usable by the AFS guys too.  Neil's patch tries to 
 address a bunch of things that I didn't, and looks better for the
 long run.
 
 

Updated to 2.4.5, with the nfs list cc'd this time in hopes of comments
or flames...

-chris

diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
+++ b/fs/nfsd/nfsfh.c   Fri Jun  1 16:08:41 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means accept any
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation  inode-i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
-   inode-i_ino,
-   inode-i_nlink, atomic_read(inode-i_count),
-   inode-i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(dcache_lock);
for (lp = inode-i_dentry.next; lp != inode-i_dentry ; lp=lp-next) {
@@ -173,6 +145,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation  inode-i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
+   inode-i_ino,
+   inode-i_nlink, atomic_read(inode-i_count),
+   inode-i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb-s_op-inode_from_fh)
+   return sb-s_op-inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb-s_op-parent_from_fh)
+   return sb-s_op-parent_from_fh(sb, datap, len) ;
+
+   if (len = 3)
+   return __inode_from_fh(sb, datap[2], 0) ;
+   return ERR_PTR(-ESTALE);
+}
+
+/* 
+ * two iget funcs, one for inode, and one for parent directory
+ *
+ * this should be provided by each filesystem in an nfsd_operations interface as
+ * iget isn't really the right interface
+ *
+ * If the filesystem doesn't provide funcs to get inodes from datap,
+ * it must be: inum, generation, dir inum.  Length of 2 means the 
+ * dir inum isn't there.
+ *
+ * iget isn't really right if the inode is currently unallocated!!
+ * This should really all be done inside each filesystem
+ *
+ * ext2fs' read_inode has been strengthed to return a bad_inode if the inode
+ *   had been deleted.
+ *
+ * Currently we don't know the generation for parent directory, so a generation
+ * of 0 means accept any
+ */
+static struct dentry *nfsd_iget(struct super_block *sb, __u32 *datap, int len)
+{
+
+   struct inode *inode;
+
+   inode = inode_from_fh(sb, datap, len) ;
+   if (IS_ERR(inode)) {
+   return ERR_PTR(PTR_ERR(inode)) ;
+   }   
+   return dentry_from_inode(inode) ;
+}
+
+static struct dentry *nfsd_parent_iget(struct super_block *sb, __u32 *datap, 
+   int len)
+{
+   struct 

Re: [NFS] Re: [RFC] yet another knfsd-reiserfs patch

2001-06-01 Thread Trond Myklebust


Hi Chris,

Do you really need the parent inode in the filehandle?

That screws rename up pretty badly, since the filehandle changes when
you rename into a different directory. It means for instance that when
I do

open(foo)
mv foo bar/
write (foo)
close(foo)

then I have a pretty good chance of getting an ESTALE on the write()
statement.

Cheers,
  Trond
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [RFC] yet another knfsd-reiserfs patch

2001-04-30 Thread Chris Mason



On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason <[EMAIL PROTECTED]> wrote:

> 
> Hi guys,
> 
> This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
> goal was to whip up something that had a chance of getting into 2.4.x,
> and that might be usable by the AFS guys too.  Neil's patch tries to 
> address a bunch of things that I didn't, and looks better for the
> long run.
>

Ok, here it is updated to 2.4.4.  The only change was to adapt to the usage
of comp_short_keys in reiserfs_iget under 2.4.4.

-chris

diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Sun Apr 29 18:01:04 2001
+++ b/fs/nfsd/nfsfh.c   Sun Apr 29 18:01:04 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means "accept any"
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation && inode->i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
-   inode->i_ino,
-   inode->i_nlink, atomic_read(>i_count),
-   inode->i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(_lock);
for (lp = inode->i_dentry.next; lp != >i_dentry ; lp=lp->next) {
@@ -172,6 +144,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation && inode->i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
+   inode->i_ino,
+   inode->i_nlink, atomic_read(>i_count),
+   inode->i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb->s_op->inode_from_fh)
+   return sb->s_op->inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb->s_op->parent_from_fh)
+   return sb->s_op->parent_from_fh(sb, datap, len) ;
+
+   if (len >= 3)
+   return __inode_from_fh(sb, datap[2], 0) ;
+   return ERR_PTR(-ESTALE);
+}
+
+/* 
+ * two iget funcs, one for inode, and one for parent directory
+ *
+ * this should be provided by each filesystem in an nfsd_operations interface as
+ * iget isn't really the right interface
+ *
+ * If the filesystem doesn't provide funcs to get inodes from datap,
+ * it must be: inum, generation, dir inum.  Length of 2 means the 
+ * dir inum isn't there.
+ *
+ * iget isn't really right if the inode is currently unallocated!!
+ * This should really all be done inside each filesystem
+ *
+ * ext2fs' read_inode has been strengthed to return a bad_inode if the inode
+ *   had been deleted.
+ *
+ * Currently we don't know the generation for parent directory, so a generation
+ * of 0 means "accept any"
+ */
+static struct dentry *nfsd_iget(struct super_block *sb, __u32 *datap, int len)
+{
+
+   struct inode *inode;
+
+   inode = inode_from_fh(sb, datap, len) ;
+   if (IS_ERR(inode)) {
+   return ERR_PTR(PTR_ERR(inode)) ;
+   }   
+   return dentry_from_inode(inode) ;
+}
+
+static struct dentry *nfsd_parent_iget(struct super_block *sb, __u32 *datap, 
+

Re: [RFC] yet another knfsd-reiserfs patch

2001-04-30 Thread Chris Mason



On Monday, April 23, 2001 10:45:14 AM -0400 Chris Mason [EMAIL PROTECTED] wrote:

 
 Hi guys,
 
 This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
 goal was to whip up something that had a chance of getting into 2.4.x,
 and that might be usable by the AFS guys too.  Neil's patch tries to 
 address a bunch of things that I didn't, and looks better for the
 long run.


Ok, here it is updated to 2.4.4.  The only change was to adapt to the usage
of comp_short_keys in reiserfs_iget under 2.4.4.

-chris

diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Sun Apr 29 18:01:04 2001
+++ b/fs/nfsd/nfsfh.c   Sun Apr 29 18:01:04 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means accept any
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation  inode-i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
-   inode-i_ino,
-   inode-i_nlink, atomic_read(inode-i_count),
-   inode-i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(dcache_lock);
for (lp = inode-i_dentry.next; lp != inode-i_dentry ; lp=lp-next) {
@@ -172,6 +144,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation  inode-i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
+   inode-i_ino,
+   inode-i_nlink, atomic_read(inode-i_count),
+   inode-i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb-s_op-inode_from_fh)
+   return sb-s_op-inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb-s_op-parent_from_fh)
+   return sb-s_op-parent_from_fh(sb, datap, len) ;
+
+   if (len = 3)
+   return __inode_from_fh(sb, datap[2], 0) ;
+   return ERR_PTR(-ESTALE);
+}
+
+/* 
+ * two iget funcs, one for inode, and one for parent directory
+ *
+ * this should be provided by each filesystem in an nfsd_operations interface as
+ * iget isn't really the right interface
+ *
+ * If the filesystem doesn't provide funcs to get inodes from datap,
+ * it must be: inum, generation, dir inum.  Length of 2 means the 
+ * dir inum isn't there.
+ *
+ * iget isn't really right if the inode is currently unallocated!!
+ * This should really all be done inside each filesystem
+ *
+ * ext2fs' read_inode has been strengthed to return a bad_inode if the inode
+ *   had been deleted.
+ *
+ * Currently we don't know the generation for parent directory, so a generation
+ * of 0 means accept any
+ */
+static struct dentry *nfsd_iget(struct super_block *sb, __u32 *datap, int len)
+{
+
+   struct inode *inode;
+
+   inode = inode_from_fh(sb, datap, len) ;
+   if (IS_ERR(inode)) {
+   return ERR_PTR(PTR_ERR(inode)) ;
+   }   
+   return dentry_from_inode(inode) ;
+}
+
+static struct dentry *nfsd_parent_iget(struct super_block *sb, __u32 *datap, 
+ 

[RFC] yet another knfsd-reiserfs patch

2001-04-23 Thread Chris Mason


Hi guys,

This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
goal was to whip up something that had a chance of getting into 2.4.x,
and that might be usable by the AFS guys too.  Neil's patch tries to 
address a bunch of things that I didn't, and looks better for the
long run.

Anyway, the basic idea is the FS provides:

int fill_fh(struct dentry *, __u32 *fh, int size) ;

fills the array of ints in fh with enough info to find the file and
its parent later.

struct inode *inode_from_fh(struct super_block *, __u32 *fh, int size) ;
struct inode *parent_from_fh(struct super_block *, __u32 *fh, int size) ;

iget the inode or parent directory inode based on data in the array.

Default ops are provided, the other filesystems should work the
same as before.  Anyway, please take a look.

-chris

# This is a BitKeeper generated patch for the following project:
# Project Name: local kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#  ChangeSet1.6 -> 1.7
#fs/reiserfs/super.c1.1 -> 1.2
#fs/nfsd/nfsfh.c1.1 -> 1.2
# include/linux/fs.h1.2 -> 1.3
#fs/reiserfs/inode.c1.1 -> 1.2
#   include/linux/reiserfs_fs.h 1.1 -> 1.2
#
# The following is the BitKeeper ChangeSet Log
# 
# 01/04/23  [EMAIL PROTECTED]  1.7
# reiserfs-knfsd-fh-ops-2
# 
# Introduce file handle operations into the super ops.  Add generic support and
# reiserfs support.   Meant for use by NFS (and perhaps AFS) to get around
# reiserfs' inability to find a file with an inode number alone.
# 
# fs.h  reiserfs-knfsd-fh-ops-2
# reiserfs_fs.h reiserfs-knfsd-fh-ops-2
# nfsfh.c   reiserfs-knfsd-fh-ops-2
# super.c   reiserfs-knfsd-fh-ops-2
# inode.c   reiserfs-knfsd-fh-ops-2
# 
#
diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Mon Apr 23 02:14:42 2001
+++ b/fs/nfsd/nfsfh.c   Mon Apr 23 02:14:42 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means "accept any"
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation && inode->i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
-   inode->i_ino,
-   inode->i_nlink, atomic_read(>i_count),
-   inode->i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(_lock);
for (lp = inode->i_dentry.next; lp != >i_dentry ; lp=lp->next) {
@@ -172,6 +144,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation && inode->i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk("fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n",
+   inode->i_ino,
+   inode->i_nlink, atomic_read(>i_count),
+   inode->i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb->s_op->inode_from_fh)
+   return sb->s_op->inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+  

[RFC] yet another knfsd-reiserfs patch

2001-04-23 Thread Chris Mason


Hi guys,

This patch is not meant to replace Neil Brown's knfsd ops stuff, the 
goal was to whip up something that had a chance of getting into 2.4.x,
and that might be usable by the AFS guys too.  Neil's patch tries to 
address a bunch of things that I didn't, and looks better for the
long run.

Anyway, the basic idea is the FS provides:

int fill_fh(struct dentry *, __u32 *fh, int size) ;

fills the array of ints in fh with enough info to find the file and
its parent later.

struct inode *inode_from_fh(struct super_block *, __u32 *fh, int size) ;
struct inode *parent_from_fh(struct super_block *, __u32 *fh, int size) ;

iget the inode or parent directory inode based on data in the array.

Default ops are provided, the other filesystems should work the
same as before.  Anyway, please take a look.

-chris

# This is a BitKeeper generated patch for the following project:
# Project Name: local kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#  ChangeSet1.6 - 1.7
#fs/reiserfs/super.c1.1 - 1.2
#fs/nfsd/nfsfh.c1.1 - 1.2
# include/linux/fs.h1.2 - 1.3
#fs/reiserfs/inode.c1.1 - 1.2
#   include/linux/reiserfs_fs.h 1.1 - 1.2
#
# The following is the BitKeeper ChangeSet Log
# 
# 01/04/23  [EMAIL PROTECTED]  1.7
# reiserfs-knfsd-fh-ops-2
# 
# Introduce file handle operations into the super ops.  Add generic support and
# reiserfs support.   Meant for use by NFS (and perhaps AFS) to get around
# reiserfs' inability to find a file with an inode number alone.
# 
# fs.h  reiserfs-knfsd-fh-ops-2
# reiserfs_fs.h reiserfs-knfsd-fh-ops-2
# nfsfh.c   reiserfs-knfsd-fh-ops-2
# super.c   reiserfs-knfsd-fh-ops-2
# inode.c   reiserfs-knfsd-fh-ops-2
# 
#
diff -Nru a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
--- a/fs/nfsd/nfsfh.c   Mon Apr 23 02:14:42 2001
+++ b/fs/nfsd/nfsfh.c   Mon Apr 23 02:14:42 2001
@@ -116,40 +116,12 @@
return error;
 }
 
-/* this should be provided by each filesystem in an nfsd_operations interface as
- * iget isn't really the right interface
- */
-static struct dentry *nfsd_iget(struct super_block *sb, unsigned long ino, __u32 
generation)
+static struct dentry *dentry_from_inode(struct inode *inode) 
 {
-
-   /* iget isn't really right if the inode is currently unallocated!!
-* This should really all be done inside each filesystem
-*
-* ext2fs' read_inode has been strengthed to return a bad_inode if the inode
-*   had been deleted.
-*
-* Currently we don't know the generation for parent directory, so a generation
-* of 0 means accept any
-*/
-   struct inode *inode;
struct list_head *lp;
struct dentry *result;
-   inode = iget(sb, ino);
-   if (is_bad_inode(inode)
-   || (generation  inode-i_generation != generation)
-   ) {
-   /* we didn't find the right inode.. */
-   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
-   inode-i_ino,
-   inode-i_nlink, atomic_read(inode-i_count),
-   inode-i_generation,
-   generation);
-
-   iput(inode);
-   return ERR_PTR(-ESTALE);
-   }
-   /* now to find a dentry.
-* If possible, get a well-connected one
+   /*
+* If possible, get a well-connected dentry
 */
spin_lock(dcache_lock);
for (lp = inode-i_dentry.next; lp != inode-i_dentry ; lp=lp-next) {
@@ -172,6 +144,92 @@
return result;
 }
 
+static struct inode *__inode_from_fh(struct super_block *sb, int ino,
+int generation) 
+{
+   struct inode *inode ;
+
+   inode = iget(sb, ino);
+   if (is_bad_inode(inode)
+   || (generation  inode-i_generation != generation)
+   ) {
+   /* we didn't find the right inode.. */
+   dprintk(fh_verify: Inode %lu, Bad count: %d %d or version  %u %u\n,
+   inode-i_ino,
+   inode-i_nlink, atomic_read(inode-i_count),
+   inode-i_generation,
+   generation);
+
+   iput(inode);
+   return ERR_PTR(-ESTALE);
+   }
+   return inode ;
+}
+
+static struct inode *inode_from_fh(struct super_block *sb, 
+   __u32 *datap,
+   int len)
+{
+   if (sb-s_op-inode_from_fh)
+   return sb-s_op-inode_from_fh(sb, datap, len) ;
+   return __inode_from_fh(sb, datap[0], datap[1]) ;
+}
+
+static struct inode *parent_from_fh(struct super_block *sb, 
+