diff options
-rw-r--r-- | fs/locks.c | 17 | ||||
-rw-r--r-- | fs/overlayfs/super.c | 2 | ||||
-rw-r--r-- | include/linux/fs.h | 13 |
3 files changed, 8 insertions, 24 deletions
diff --git a/fs/locks.c b/fs/locks.c index baa564841c03..dab4e72f8bff 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -139,11 +139,6 @@ | |||
139 | #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) | 139 | #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) |
140 | #define IS_REMOTELCK(fl) (fl->fl_pid <= 0) | 140 | #define IS_REMOTELCK(fl) (fl->fl_pid <= 0) |
141 | 141 | ||
142 | static inline bool is_remote_lock(struct file *filp) | ||
143 | { | ||
144 | return likely(!(filp->f_path.dentry->d_sb->s_flags & SB_NOREMOTELOCK)); | ||
145 | } | ||
146 | |||
147 | static bool lease_breaking(struct file_lock *fl) | 142 | static bool lease_breaking(struct file_lock *fl) |
148 | { | 143 | { |
149 | return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); | 144 | return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); |
@@ -1875,7 +1870,7 @@ EXPORT_SYMBOL(generic_setlease); | |||
1875 | int | 1870 | int |
1876 | vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv) | 1871 | vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv) |
1877 | { | 1872 | { |
1878 | if (filp->f_op->setlease && is_remote_lock(filp)) | 1873 | if (filp->f_op->setlease) |
1879 | return filp->f_op->setlease(filp, arg, lease, priv); | 1874 | return filp->f_op->setlease(filp, arg, lease, priv); |
1880 | else | 1875 | else |
1881 | return generic_setlease(filp, arg, lease, priv); | 1876 | return generic_setlease(filp, arg, lease, priv); |
@@ -2022,7 +2017,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) | |||
2022 | if (error) | 2017 | if (error) |
2023 | goto out_free; | 2018 | goto out_free; |
2024 | 2019 | ||
2025 | if (f.file->f_op->flock && is_remote_lock(f.file)) | 2020 | if (f.file->f_op->flock) |
2026 | error = f.file->f_op->flock(f.file, | 2021 | error = f.file->f_op->flock(f.file, |
2027 | (can_sleep) ? F_SETLKW : F_SETLK, | 2022 | (can_sleep) ? F_SETLKW : F_SETLK, |
2028 | lock); | 2023 | lock); |
@@ -2048,7 +2043,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) | |||
2048 | */ | 2043 | */ |
2049 | int vfs_test_lock(struct file *filp, struct file_lock *fl) | 2044 | int vfs_test_lock(struct file *filp, struct file_lock *fl) |
2050 | { | 2045 | { |
2051 | if (filp->f_op->lock && is_remote_lock(filp)) | 2046 | if (filp->f_op->lock) |
2052 | return filp->f_op->lock(filp, F_GETLK, fl); | 2047 | return filp->f_op->lock(filp, F_GETLK, fl); |
2053 | posix_test_lock(filp, fl); | 2048 | posix_test_lock(filp, fl); |
2054 | return 0; | 2049 | return 0; |
@@ -2191,7 +2186,7 @@ out: | |||
2191 | */ | 2186 | */ |
2192 | int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) | 2187 | int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) |
2193 | { | 2188 | { |
2194 | if (filp->f_op->lock && is_remote_lock(filp)) | 2189 | if (filp->f_op->lock) |
2195 | return filp->f_op->lock(filp, cmd, fl); | 2190 | return filp->f_op->lock(filp, cmd, fl); |
2196 | else | 2191 | else |
2197 | return posix_lock_file(filp, fl, conf); | 2192 | return posix_lock_file(filp, fl, conf); |
@@ -2513,7 +2508,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx) | |||
2513 | if (list_empty(&flctx->flc_flock)) | 2508 | if (list_empty(&flctx->flc_flock)) |
2514 | return; | 2509 | return; |
2515 | 2510 | ||
2516 | if (filp->f_op->flock && is_remote_lock(filp)) | 2511 | if (filp->f_op->flock) |
2517 | filp->f_op->flock(filp, F_SETLKW, &fl); | 2512 | filp->f_op->flock(filp, F_SETLKW, &fl); |
2518 | else | 2513 | else |
2519 | flock_lock_inode(inode, &fl); | 2514 | flock_lock_inode(inode, &fl); |
@@ -2600,7 +2595,7 @@ EXPORT_SYMBOL(posix_unblock_lock); | |||
2600 | */ | 2595 | */ |
2601 | int vfs_cancel_lock(struct file *filp, struct file_lock *fl) | 2596 | int vfs_cancel_lock(struct file *filp, struct file_lock *fl) |
2602 | { | 2597 | { |
2603 | if (filp->f_op->lock && is_remote_lock(filp)) | 2598 | if (filp->f_op->lock) |
2604 | return filp->f_op->lock(filp, F_CANCELLK, fl); | 2599 | return filp->f_op->lock(filp, F_CANCELLK, fl); |
2605 | return 0; | 2600 | return 0; |
2606 | } | 2601 | } |
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 5bc261de5041..c63beccad4fc 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
@@ -1456,7 +1456,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
1456 | sb->s_op = &ovl_super_operations; | 1456 | sb->s_op = &ovl_super_operations; |
1457 | sb->s_xattr = ovl_xattr_handlers; | 1457 | sb->s_xattr = ovl_xattr_handlers; |
1458 | sb->s_fs_info = ofs; | 1458 | sb->s_fs_info = ofs; |
1459 | sb->s_flags |= SB_POSIXACL | SB_NOREMOTELOCK; | 1459 | sb->s_flags |= SB_POSIXACL; |
1460 | 1460 | ||
1461 | err = -ENOMEM; | 1461 | err = -ENOMEM; |
1462 | root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0)); | 1462 | root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0)); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 16e2741cec3c..1cbcf37c45e1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1054,17 +1054,7 @@ struct file_lock_context { | |||
1054 | 1054 | ||
1055 | extern void send_sigio(struct fown_struct *fown, int fd, int band); | 1055 | extern void send_sigio(struct fown_struct *fown, int fd, int band); |
1056 | 1056 | ||
1057 | /* | 1057 | #define locks_inode(f) file_inode(f) |
1058 | * Return the inode to use for locking | ||
1059 | * | ||
1060 | * For overlayfs this should be the overlay inode, not the real inode returned | ||
1061 | * by file_inode(). For any other fs file_inode(filp) and locks_inode(filp) are | ||
1062 | * equal. | ||
1063 | */ | ||
1064 | static inline struct inode *locks_inode(const struct file *f) | ||
1065 | { | ||
1066 | return f->f_path.dentry->d_inode; | ||
1067 | } | ||
1068 | 1058 | ||
1069 | #ifdef CONFIG_FILE_LOCKING | 1059 | #ifdef CONFIG_FILE_LOCKING |
1070 | extern int fcntl_getlk(struct file *, unsigned int, struct flock *); | 1060 | extern int fcntl_getlk(struct file *, unsigned int, struct flock *); |
@@ -1305,7 +1295,6 @@ extern int send_sigurg(struct fown_struct *fown); | |||
1305 | 1295 | ||
1306 | /* These sb flags are internal to the kernel */ | 1296 | /* These sb flags are internal to the kernel */ |
1307 | #define SB_SUBMOUNT (1<<26) | 1297 | #define SB_SUBMOUNT (1<<26) |
1308 | #define SB_NOREMOTELOCK (1<<27) | ||
1309 | #define SB_NOSEC (1<<28) | 1298 | #define SB_NOSEC (1<<28) |
1310 | #define SB_BORN (1<<29) | 1299 | #define SB_BORN (1<<29) |
1311 | #define SB_ACTIVE (1<<30) | 1300 | #define SB_ACTIVE (1<<30) |