diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 387c5823944eddc95d2b99fe14e55547f80ef83e..e38423e82f2ebe3f311a3f173964181c5ebe1860 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -62,13 +62,16 @@ static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
 		*max_len = connected_handle_length;
 		type = 2;
 	} else if (*max_len >= handle_length) {
-		if (connectable)
+		if (connectable) {
+			*max_len = connected_handle_length;
 			return 255;
+		}
 		dout("encode_fh %p\n", dentry);
 		fh->ino = ceph_ino(dentry->d_inode);
 		*max_len = handle_length;
 		type = 1;
 	} else {
+		*max_len = handle_length;
 		return 255;
 	}
 	return type;