From: Linus Torvalds Date: Wed, 13 Jan 2016 00:30:34 +0000 (-0800) Subject: Merge branch 'work.copy_file_range' of git://git.kernel.org/pub/scm/linux/kernel... X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=fce205e9da8e063aa1cf3d6583c1a9ed2b82f3f0;p=openwrt%2Fstaging%2Fblogic.git Merge branch 'work.copy_file_range' of git://git./linux/kernel/git/viro/vfs Pull vfs copy_file_range updates from Al Viro: "Several series around copy_file_range/CLONE" * 'work.copy_file_range' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: btrfs: use new dedupe data function pointer vfs: hoist the btrfs deduplication ioctl to the vfs vfs: wire up compat ioctl for CLONE/CLONE_RANGE cifs: avoid unused variable and label nfsd: implement the NFSv4.2 CLONE operation nfsd: Pass filehandle to nfs4_preprocess_stateid_op() vfs: pull btrfs clone API to vfs layer locks: new locks_mandatory_area calling convention vfs: Add vfs_copy_file_range() support for pagecache copies btrfs: add .copy_file_range file operation x86: add sys_copy_file_range to syscall tables vfs: add copy_file_range syscall and vfs helper --- fce205e9da8e063aa1cf3d6583c1a9ed2b82f3f0 diff --cc include/linux/fs.h index 566f8e078ffc,d71814b81a3c..ec43a24bf63d --- a/include/linux/fs.h +++ b/include/linux/fs.h @@@ -2027,12 -2039,9 +2039,9 @@@ extern struct kobject *fs_kobj #define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK) - #define FLOCK_VERIFY_READ 1 - #define FLOCK_VERIFY_WRITE 2 - -#ifdef CONFIG_FILE_LOCKING +#ifdef CONFIG_MANDATORY_FILE_LOCKING extern int locks_mandatory_locked(struct file *); - extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); + extern int locks_mandatory_area(struct inode *, struct file *, loff_t, loff_t, unsigned char); /* * Candidates for mandatory locking have the setgid bit set @@@ -2062,58 -2071,21 +2071,59 @@@ static inline int locks_verify_locked(s } static inline int locks_verify_truncate(struct inode *inode, - struct file *filp, + struct file *f, loff_t size) { - if (inode->i_flctx && mandatory_lock(inode)) - return locks_mandatory_area( - FLOCK_VERIFY_WRITE, inode, filp, - size < inode->i_size ? size : inode->i_size, - (size < inode->i_size ? inode->i_size - size - : size - inode->i_size) - ); - return 0; + if (!inode->i_flctx || !mandatory_lock(inode)) + return 0; + + if (size < inode->i_size) { + return locks_mandatory_area(inode, f, size, inode->i_size - 1, + F_WRLCK); + } else { + return locks_mandatory_area(inode, f, inode->i_size, size - 1, + F_WRLCK); + } } +#else /* !CONFIG_MANDATORY_FILE_LOCKING */ + +static inline int locks_mandatory_locked(struct file *file) +{ + return 0; +} + - static inline int locks_mandatory_area(int rw, struct inode *inode, - struct file *filp, loff_t offset, - size_t count) ++static inline int locks_mandatory_area(struct inode *inode, struct file *filp, ++ loff_t start, loff_t end, unsigned char type) +{ + return 0; +} + +static inline int __mandatory_lock(struct inode *inode) +{ + return 0; +} + +static inline int mandatory_lock(struct inode *inode) +{ + return 0; +} + +static inline int locks_verify_locked(struct file *file) +{ + return 0; +} + +static inline int locks_verify_truncate(struct inode *inode, struct file *filp, + size_t size) +{ + return 0; +} + +#endif /* CONFIG_MANDATORY_FILE_LOCKING */ + + +#ifdef CONFIG_FILE_LOCKING static inline int break_lease(struct inode *inode, unsigned int mode) { /*