Skip to contentSkip to conversation

exportfs: add FILEID_INVALID to indicate invalid fid_type

PATCH In review Namjae Jeon 2 participants 3 messages Aug 29, 2012 – Aug 30, 2012

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

PATCH 1/1 exportfs: add FILEID_INVALID to indicate invalid fid_type

This commit adds FILEID_INVALID = 0xff in fid_type to indicate invalid fid_type

It avoids using magic number 255

---
 fs/exportfs/expfs.c      |    4 ++--
 fs/fhandle.c             |    2 +-
 fs/nfsd/nfsfh.c          |    4 ++--
 include/linux/exportfs.h |    5 +++++
 4 files changed, 10 insertions(+), 5 deletions(-)
fs/exportfs/expfs.c +2 -2
index 29ab099..f1f1c59 100644
@@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
 
 	if (parent && (len < 4)) {
 		*max_len = 4;
-		return 255;
+		return FILEID_INVALID;
 	} else if (len < 2) {
 		*max_len = 2;
-		return 255;
+		return FILEID_INVALID;
 	}
 
 	len = 2;
fs/fhandle.c +1 -1
index a48e4a1..78a7879 100644
@@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path,
 	handle_bytes = handle_dwords * sizeof(u32);
 	handle->handle_bytes = handle_bytes;
 	if ((handle->handle_bytes > f_handle.handle_bytes) ||
-	    (retval == 255) || (retval == -ENOSPC)) {
+	    (retval == FILEID_INVALID) || (retval == -ENOSPC)) {
 		/* As per old exportfs_encode_fh documentation
 		 * we could return ENOSPC to indicate overflow
 		 * But file system returned 255 always. So handle
fs/nfsd/nfsfh.c +2 -2
index 032af38..814afaa 100644
@@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
 
 		if (inode)
 			_fh_update(fhp, exp, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255) {
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
 			fh_put(fhp);
 			return nfserr_opnotsupp;
 		}
@@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp)
 			goto out;
 
 		_fh_update(fhp, fhp->fh_export, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255)
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
 			return nfserr_opnotsupp;
 	}
 out:
include/linux/exportfs.h +5 -0
index 12291a7..0e14525 100644
@@ -83,6 +83,11 @@ enum fid_type {
 	 * 64 bit parent inode number.
 	 */
 	FILEID_NILFS_WITH_PARENT = 0x62,
+
+	/*
+	 * Filesystems must not use 0xff file ID.
+	 */
+	FILEID_INVALID = 0xff,
 };
 
 struct fid {
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 2 lines · Namjae Jeon

This commit adds FILEID_INVALID = 0xff in fid_type to indicate invalid fid_type

OK, applying for 3.7.

Looks like this shows up in a lot of filesystems too as just "255". Are you planning to patch up the filesystems afterwards?

--b.

Quoted 83 lines

It avoids using magic number 255

---
 fs/exportfs/expfs.c      |    4 ++--
 fs/fhandle.c             |    2 +-
 fs/nfsd/nfsfh.c          |    4 ++--
 include/linux/exportfs.h |    5 +++++
 4 files changed, 10 insertions(+), 5 deletions(-)
fs/exportfs/expfs.c +2 -2
index 29ab099..f1f1c59 100644
@@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
 
 	if (parent && (len < 4)) {
 		*max_len = 4;
-		return 255;
+		return FILEID_INVALID;
 	} else if (len < 2) {
 		*max_len = 2;
-		return 255;
+		return FILEID_INVALID;
 	}
 
 	len = 2;
fs/fhandle.c +1 -1
index a48e4a1..78a7879 100644
@@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path,
 	handle_bytes = handle_dwords * sizeof(u32);
 	handle->handle_bytes = handle_bytes;
 	if ((handle->handle_bytes > f_handle.handle_bytes) ||
-	    (retval == 255) || (retval == -ENOSPC)) {
+	    (retval == FILEID_INVALID) || (retval == -ENOSPC)) {
 		/* As per old exportfs_encode_fh documentation
 		 * we could return ENOSPC to indicate overflow
 		 * But file system returned 255 always. So handle
fs/nfsd/nfsfh.c +2 -2
index 032af38..814afaa 100644
@@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
 
 		if (inode)
 			_fh_update(fhp, exp, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255) {
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
 			fh_put(fhp);
 			return nfserr_opnotsupp;
 		}
@@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp)
 			goto out;
 
 		_fh_update(fhp, fhp->fh_export, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255)
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
 			return nfserr_opnotsupp;
 	}
 out:
include/linux/exportfs.h +5 -0
index 12291a7..0e14525 100644
@@ -83,6 +83,11 @@ enum fid_type {
 	 * 64 bit parent inode number.
 	 */
 	FILEID_NILFS_WITH_PARENT = 0x62,
+
+	/*
+	 * Filesystems must not use 0xff file ID.
+	 */
+	FILEID_INVALID = 0xff,
 };
 
 struct fid {
Signature · 1 line
1.7.9.5
#2 lore raw

2012/8/31, J. Bruce Fields <[email protected]>:

Quoted 8 lines · Namjae Jeon
Quoted 2 lines

This commit adds FILEID_INVALID = 0xff in fid_type to indicate invalid fid_type

OK, applying for 3.7.

Looks like this shows up in a lot of filesystems too as just "255". Are you planning to patch up the filesystems afterwards?

Hi Bruce.
Yes, I will fix these from next patches.
Thanks.

Quoted 89 lines

--b.

Quoted 85 lines

It avoids using magic number 255

---
 fs/exportfs/expfs.c      |    4 ++--
 fs/fhandle.c             |    2 +-
 fs/nfsd/nfsfh.c          |    4 ++--
 include/linux/exportfs.h |    5 +++++
 4 files changed, 10 insertions(+), 5 deletions(-)
fs/exportfs/expfs.c +2 -2
index 29ab099..f1f1c59 100644
@@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode,
 struct fid *fid,
 
 	if (parent && (len < 4)) {
 		*max_len = 4;
-		return 255;
+		return FILEID_INVALID;
 	} else if (len < 2) {
 		*max_len = 2;
-		return 255;
+		return FILEID_INVALID;
 	}
 
fs/exportfs/expfs.c +0 -0
 	len = 2;
fs/fhandle.c +1 -1
index a48e4a1..78a7879 100644
@@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path,
 	handle_bytes = handle_dwords * sizeof(u32);
 	handle->handle_bytes = handle_bytes;
 	if ((handle->handle_bytes > f_handle.handle_bytes) ||
-	    (retval == 255) || (retval == -ENOSPC)) {
+	    (retval == FILEID_INVALID) || (retval == -ENOSPC)) {
 		/* As per old exportfs_encode_fh documentation
 		 * we could return ENOSPC to indicate overflow
 		 * But file system returned 255 always. So handle
fs/nfsd/nfsfh.c +1 -1
index 032af38..814afaa 100644
@@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp,
 struct dentry *dentry,
 
 		if (inode)
 			_fh_update(fhp, exp, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255) {
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
 			fh_put(fhp);
 			return nfserr_opnotsupp;
fs/nfsd/nfsfh.c +1 -1
 		}
@@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp)
 			goto out;
 
 		_fh_update(fhp, fhp->fh_export, dentry);
-		if (fhp->fh_handle.fh_fileid_type == 255)
+		if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
 			return nfserr_opnotsupp;
 	}
 out:
include/linux/exportfs.h +5 -1
index 12291a7..0e14525 100644
@@ -83,6 +83,11 @@ enum fid_type {
 	 * 64 bit parent inode number.
 	 */
 	FILEID_NILFS_WITH_PARENT = 0x62,
+
+	/*
+	 * Filesystems must not use 0xff file ID.
+	 */
+	FILEID_INVALID = 0xff,
 };
 
 struct fid {
--

1.7.9.5