Skip to contentSkip to conversation

allow file system to configure for no leases

PATCH In review Peter Staubach 2 participants 4 messages Jun 5, 2007 – Jun 6, 2007

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

PATCH 1/1 allow file system to configure for no leases

Hi.

Attached is a small patch to allow file systems to inform the file system independent layers that they don't support file leases.

The problem is that some file system such as NFSv2 and NFSv3 do not have sufficient support to be able to support leases correctly. In particular for these two file systems, there is no over the wire protocol support.

Currently, these two file systems fail the fcntl(F_SETLEASE) call accidently, due to a reference counting difference. These file systems should fail more consciously, with a proper error to indicate that the call is invalid for them.

Thanx...

ps

fs/nfs/super.c renamed from fs/nfs/super.c.org +3 -0
@@ -522,6 +522,9 @@ static inline void nfs_initialise_sb(str
 
 	sb->s_magic = NFS_SUPER_MAGIC;
 
+	if (server->nfs_client->cl_nfsversion < 4)
+		sb->s_flags |= MS_NO_LEASES;
+
 	/* We probably want something more informative here */
 	snprintf(sb->s_id, sizeof(sb->s_id),
 		 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
fs/locks.c renamed from fs/locks.c.org +2 -0
@@ -1493,6 +1493,8 @@ int fcntl_setlease(unsigned int fd, stru
 	error = security_file_lock(filp, arg);
 	if (error)
 		return error;
+	if (IS_NO_LEASES(inode))
+		return -EINVAL;
 
 	locks_init_lock(&fl);
 	error = lease_init(filp, arg, &fl);
include/linux/fs.h renamed from include/linux/fs.h.org +2 -0
@@ -121,6 +121,7 @@ extern int dir_notify_enable;
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
 #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
+#define MS_NO_LEASES	(1<<22)	/* fs does not support leases */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -180,6 +181,7 @@ extern int dir_notify_enable;
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode)	((inode)->i_flags & S_SWAPFILE)
 #define IS_PRIVATE(inode)	((inode)->i_flags & S_PRIVATE)
+#define IS_NO_LEASES(inode)	__IS_FLG(inode, MS_NO_LEASES)
 
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
#1 lore raw
Quoted 22 lines · Peter Staubach

Hi.

Attached is a small patch to allow file systems to inform the file system independent layers that they don't support file leases.

The problem is that some file system such as NFSv2 and NFSv3 do not have sufficient support to be able to support leases correctly. In particular for these two file systems, there is no over the wire protocol support.

Currently, these two file systems fail the fcntl(F_SETLEASE) call accidently, due to a reference counting difference. These file systems should fail more consciously, with a proper error to indicate that the call is invalid for them.

    Thanx...

       ps

plain text document attachment (devel.tototoday)

fs/nfs/super.c static inline void nfs_initialise_sb(str · line 527

Quoted 6 lines
fs/nfs/super.c renamed from fs/nfs/super.c.org +3 -0
@@ -522,6 +522,9 @@ static inline void nfs_initialise_sb(str
 
 	sb->s_magic = NFS_SUPER_MAGIC;
 
+	if (server->nfs_client->cl_nfsversion < 4)
+		sb->s_flags |= MS_NO_LEASES;
+

This should be unconditional since we have no support for "lease locks" under NFSv4 either. The NFSv4 concept of leases and delegations is very different, since it is really tied to the ability to cache data.

Quoted 32 lines
fs/nfs/super.c renamed from fs/nfs/super.c.org +0 -0
 	/* We probably want something more informative here */
 	snprintf(sb->s_id, sizeof(sb->s_id),
 		 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
fs/locks.c renamed from fs/locks.c.org +2 -0
@@ -1493,6 +1493,8 @@ int fcntl_setlease(unsigned int fd, stru
 	error = security_file_lock(filp, arg);
 	if (error)
 		return error;
+	if (IS_NO_LEASES(inode))
+		return -EINVAL;
 
 	locks_init_lock(&fl);
 	error = lease_init(filp, arg, &fl);
include/linux/fs.h renamed from include/linux/fs.h.org +2 -0
@@ -121,6 +121,7 @@ extern int dir_notify_enable;
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
 #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
+#define MS_NO_LEASES	(1<<22)	/* fs does not support leases */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -180,6 +181,7 @@ extern int dir_notify_enable;
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode)	((inode)->i_flags & S_SWAPFILE)
 #define IS_PRIVATE(inode)	((inode)->i_flags & S_PRIVATE)
+#define IS_NO_LEASES(inode)	__IS_FLG(inode, MS_NO_LEASES)
 
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
#2 lore raw
Quoted 27 lines · Trond Myklebust
Quoted 25 lines · Peter Staubach

Hi.

Attached is a small patch to allow file systems to inform the file system independent layers that they don't support file leases.

The problem is that some file system such as NFSv2 and NFSv3 do not have sufficient support to be able to support leases correctly. In particular for these two file systems, there is no over the wire protocol support.

Currently, these two file systems fail the fcntl(F_SETLEASE) call accidently, due to a reference counting difference. These file systems should fail more consciously, with a proper error to indicate that the call is invalid for them.

    Thanx...

       ps

plain text document attachment (devel.tototoday)

fs/nfs/super.c renamed from fs/nfs/super.c.org +0 -0
@@ -522,6 +522,9 @@ static inline void nfs_initialise_sb(str
 
 	sb->s_magic = NFS_SUPER_MAGIC;
 
Quoted 8 lines

fs/nfs/super.c static inline void nfs_initialise_sb(str · line 528

Quoted 4 lines
fs/nfs/super.c renamed from fs/nfs/super.c.org +3 -0
+	if (server->nfs_client->cl_nfsversion < 4)
+		sb->s_flags |= MS_NO_LEASES;
+
 

This should be unconditional since we have no support for "lease locks" under NFSv4 either. The NFSv4 concept of leases and delegations is very different, since it is really tied to the ability to cache data.

No problem. I wasn't sure, what with the changes that Bruce Fields is constructing.

Attached is the simplified version.

Thanx...

ps

fs/nfs/super.c renamed from fs/nfs/super.c.org +2 -0
@@ -522,6 +522,8 @@ static inline void nfs_initialise_sb(str
 
 	sb->s_magic = NFS_SUPER_MAGIC;
 
+	sb->s_flags |= MS_NO_LEASES;
+
 	/* We probably want something more informative here */
 	snprintf(sb->s_id, sizeof(sb->s_id),
 		 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
fs/locks.c renamed from fs/locks.c.org +2 -0
@@ -1493,6 +1493,8 @@ int fcntl_setlease(unsigned int fd, stru
 	error = security_file_lock(filp, arg);
 	if (error)
 		return error;
+	if (IS_NO_LEASES(inode))
+		return -EINVAL;
 
 	locks_init_lock(&fl);
 	error = lease_init(filp, arg, &fl);
include/linux/fs.h renamed from include/linux/fs.h.org +2 -0
@@ -121,6 +121,7 @@ extern int dir_notify_enable;
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
 #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
+#define MS_NO_LEASES	(1<<22)	/* fs does not support leases */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -180,6 +181,7 @@ extern int dir_notify_enable;
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode)	((inode)->i_flags & S_SWAPFILE)
 #define IS_PRIVATE(inode)	((inode)->i_flags & S_PRIVATE)
+#define IS_NO_LEASES(inode)	__IS_FLG(inode, MS_NO_LEASES)
 
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
#3 lore raw

Hi.

Attached is a small patch to allow file systems to inform the file system independent layers that they don't support file leases.

The problem is that some file system such as NFSv2 and NFSv3 do not have sufficient support to be able to support leases correctly. In particular for these two file systems, there is no over the wire protocol support.

Currently, these two file systems fail the fcntl(F_SETLEASE) call accidentally, due to a reference counting difference. These file systems should fail more consciously, with a proper error to indicate that the call is invalid for them.

Thanx...

ps

fs/nfs/super.c renamed from fs/nfs/super.c.org +2 -0
@@ -522,6 +522,8 @@ static inline void nfs_initialise_sb(str
 
 	sb->s_magic = NFS_SUPER_MAGIC;
 
+	sb->s_flags |= MS_NO_LEASES;
+
 	/* We probably want something more informative here */
 	snprintf(sb->s_id, sizeof(sb->s_id),
 		 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
fs/locks.c renamed from fs/locks.c.org +2 -0
@@ -1493,6 +1493,8 @@ int fcntl_setlease(unsigned int fd, stru
 	error = security_file_lock(filp, arg);
 	if (error)
 		return error;
+	if (IS_NO_LEASES(inode))
+		return -EINVAL;
 
 	locks_init_lock(&fl);
 	error = lease_init(filp, arg, &fl);
include/linux/fs.h renamed from include/linux/fs.h.org +2 -0
@@ -121,6 +121,7 @@ extern int dir_notify_enable;
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
 #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
+#define MS_NO_LEASES	(1<<22)	/* fs does not support leases */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -180,6 +181,7 @@ extern int dir_notify_enable;
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode)	((inode)->i_flags & S_SWAPFILE)
 #define IS_PRIVATE(inode)	((inode)->i_flags & S_PRIVATE)
+#define IS_NO_LEASES(inode)	__IS_FLG(inode, MS_NO_LEASES)
 
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */