ext2 reservations: fix for r/o bind mounts: take-writer-count (v2)
PATCH 1/1 ext2 reservations: fix for r/o bind mounts: take-writer-count (v2)
Please throw away what I send a moment ago, it was the wrong patch.
This is on top of the ext2-reservations.patch in -mm.
The original r/o bind mount set didn't address the new ext2 ioctl: EXT2_IOC_SETRSVSZ, because it doesn't exist in mainline. This fixes that up for -mm.
Signed-off-by Dave Hansen <[email protected]>
---
lxc-dave/fs/ext2/ioctl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
fs/ext2/ioctl.c renamed from fs/ext2/ioctl.c~ext2-reservations-take-writer-count +15 -9
@@ -111,14 +111,18 @@ setflags_out:if (!test_opt (inode->i_sb,RESERVATION ) ||!S_ISREG (inode->i_mode))return -ENOTTY ; -if (IS_RDONLY (inode)) -return -EROFS ; - -if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER )) -return -EACCES ; - -if (get_user (rsv_window_size, (int __user *)arg)) -return -EFAULT ; + ret =mnt_want_write (filp->f_vfsmnt); +if (ret) +return ret; + +if ((current->fsuid != inode->i_uid) && !capable (CAP_FOWNER )) { + ret = -EACCES ; + goto setrsvsz_out; + } +if (get_user (rsv_window_size, (int __user *)arg)) { + ret = -EFAULT ; + goto setrsvsz_out; + }if (rsv_window_size >EXT2_MAX_RESERVE_BLOCKS ) rsv_window_size =EXT2_MAX_RESERVE_BLOCKS ;
@@ -140,7 +144,9 @@ setflags_out: rsv->rsv_goal_size = rsv_window_size; }mutex_unlock (&ei->truncate_mutex); -return 0 ; + setrsvsz_out: +mnt_drop_write (filp->f_vfsmnt); +return ret; }default :return -ENOTTY ;
diff -puN fs/namespace.c~ext2-reservations-take-writer-count fs/namespace.c _