Skip to content

Commit 92923dc

Browse files
kvaneeshliewegas
authored andcommitted
ceph: Fix return value of encode_fh function
encode_fh function should return 255 on error as done by other file system to indicate EOVERFLOW. Also max_len is in sizeof(u32) units and not in bytes. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Sage Weil <sage@newdream.net>
1 parent 6bc1887 commit 92923dc

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎fs/ceph/export.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,34 @@ struct ceph_nfs_confh {
4242
static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
4343
int connectable)
4444
{
45+
int type;
4546
struct ceph_nfs_fh *fh = (void *)rawfh;
4647
struct ceph_nfs_confh *cfh = (void *)rawfh;
4748
struct dentry *parent = dentry->d_parent;
4849
struct inode *inode = dentry->d_inode;
49-
int type;
50+
int connected_handle_length = sizeof(*cfh)/4;
51+
int handle_length = sizeof(*fh)/4;
5052

5153
/* don't re-export snaps */
5254
if (ceph_snap(inode) != CEPH_NOSNAP)
5355
return -EINVAL;
5456

55-
if (*max_len >= sizeof(*cfh)) {
57+
if (*max_len >= connected_handle_length) {
5658
dout("encode_fh %p connectable\n", dentry);
5759
cfh->ino = ceph_ino(dentry->d_inode);
5860
cfh->parent_ino = ceph_ino(parent->d_inode);
5961
cfh->parent_name_hash = parent->d_name.hash;
60-
*max_len = sizeof(*cfh);
62+
*max_len = connected_handle_length;
6163
type = 2;
62-
} else if (*max_len > sizeof(*fh)) {
64+
} else if (*max_len >= handle_length) {
6365
if (connectable)
64-
return -ENOSPC;
66+
return 255;
6567
dout("encode_fh %p\n", dentry);
6668
fh->ino = ceph_ino(dentry->d_inode);
67-
*max_len = sizeof(*fh);
69+
*max_len = handle_length;
6870
type = 1;
6971
} else {
70-
return -ENOSPC;
72+
return 255;
7173
}
7274
return type;
7375
}

0 commit comments

Comments
 (0)