diff mbox

[1/3] BTRFS: support NFSv2 export

Message ID 20150508001623.31129.91695.stgit@notabene.brown (mailing list archive)
State Accepted
Headers show

Commit Message

NeilBrown May 8, 2015, 12:16 a.m. UTC
The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
that returned by encode_fh - it may be larger.

With NFSv2, the filehandle is fixed length, so it may appear longer
than expected and be zero-padded.

So we must test that fh_len is at least some value, not exactly equal
to it.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 fs/btrfs/export.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Sterba May 11, 2015, 8:13 a.m. UTC | #1
On Fri, May 08, 2015 at 10:16:23AM +1000, NeilBrown wrote:
> The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
> that returned by encode_fh - it may be larger.
> 
> With NFSv2, the filehandle is fixed length, so it may appear longer
> than expected and be zero-padded.
> 
> So we must test that fh_len is at least some value, not exactly equal
> to it.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>

Acked-by: David Sterba <dsterba@suse.cz>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
NeilBrown Sept. 24, 2015, 1:59 a.m. UTC | #2
David Sterba <dsterba@suse.cz> writes:

> On Fri, May 08, 2015 at 10:16:23AM +1000, NeilBrown wrote:
>> The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
>> that returned by encode_fh - it may be larger.
>> 
>> With NFSv2, the filehandle is fixed length, so it may appear longer
>> than expected and be zero-padded.
>> 
>> So we must test that fh_len is at least some value, not exactly equal
>> to it.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.de>
>
> Acked-by: David Sterba <dsterba@suse.cz>

Thanks.  However I just checked mainline and this still hasn't been
applied.
Should I resend it to someone?  Who?

Thanks,
NeilBrown
Chris Mason Oct. 5, 2015, 2:32 p.m. UTC | #3
On Thu, Sep 24, 2015 at 11:59:02AM +1000, Neil Brown wrote:
> David Sterba <dsterba@suse.cz> writes:
> 
> > On Fri, May 08, 2015 at 10:16:23AM +1000, NeilBrown wrote:
> >> The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
> >> that returned by encode_fh - it may be larger.
> >> 
> >> With NFSv2, the filehandle is fixed length, so it may appear longer
> >> than expected and be zero-padded.
> >> 
> >> So we must test that fh_len is at least some value, not exactly equal
> >> to it.
> >> 
> >> Signed-off-by: NeilBrown <neilb@suse.de>
> >
> > Acked-by: David Sterba <dsterba@suse.cz>
> 
> Thanks.  However I just checked mainline and this still hasn't been
> applied.
> Should I resend it to someone?  Who?


Sorry Neil, I thought you were pushing these after it was ack'd.  I'll
put it in my pull this week.

-chris

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 8d052209f473..2513a7f53334 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -112,11 +112,11 @@  static struct dentry *btrfs_fh_to_parent(struct super_block *sb, struct fid *fh,
 	u32 generation;
 
 	if (fh_type == FILEID_BTRFS_WITH_PARENT) {
-		if (fh_len !=  BTRFS_FID_SIZE_CONNECTABLE)
+		if (fh_len <  BTRFS_FID_SIZE_CONNECTABLE)
 			return NULL;
 		root_objectid = fid->root_objectid;
 	} else if (fh_type == FILEID_BTRFS_WITH_PARENT_ROOT) {
-		if (fh_len != BTRFS_FID_SIZE_CONNECTABLE_ROOT)
+		if (fh_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT)
 			return NULL;
 		root_objectid = fid->parent_root_objectid;
 	} else
@@ -136,11 +136,11 @@  static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
 	u32 generation;
 
 	if ((fh_type != FILEID_BTRFS_WITH_PARENT ||
-	     fh_len != BTRFS_FID_SIZE_CONNECTABLE) &&
+	     fh_len < BTRFS_FID_SIZE_CONNECTABLE) &&
 	    (fh_type != FILEID_BTRFS_WITH_PARENT_ROOT ||
-	     fh_len != BTRFS_FID_SIZE_CONNECTABLE_ROOT) &&
+	     fh_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT) &&
 	    (fh_type != FILEID_BTRFS_WITHOUT_PARENT ||
-	     fh_len != BTRFS_FID_SIZE_NON_CONNECTABLE))
+	     fh_len < BTRFS_FID_SIZE_NON_CONNECTABLE))
 		return NULL;
 
 	objectid = fid->objectid;