Merge branch 'work.copy_file_range' of git://git.kernel.org/pub/scm/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
This commit is contained in:
@@ -1630,6 +1630,12 @@ struct file_operations {
|
||||
#ifndef CONFIG_MMU
|
||||
unsigned (*mmap_capabilities)(struct file *);
|
||||
#endif
|
||||
ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
|
||||
loff_t, size_t, unsigned int);
|
||||
int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t,
|
||||
u64);
|
||||
ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *,
|
||||
u64);
|
||||
};
|
||||
|
||||
struct inode_operations {
|
||||
@@ -1680,6 +1686,12 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
|
||||
unsigned long, loff_t *);
|
||||
extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
|
||||
unsigned long, loff_t *);
|
||||
extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
|
||||
loff_t, size_t, unsigned int);
|
||||
extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
|
||||
struct file *file_out, loff_t pos_out, u64 len);
|
||||
extern int vfs_dedupe_file_range(struct file *file,
|
||||
struct file_dedupe_range *same);
|
||||
|
||||
struct super_operations {
|
||||
struct inode *(*alloc_inode)(struct super_block *sb);
|
||||
@@ -2027,12 +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_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,17 +2071,19 @@ static inline int locks_verify_locked(struct file *file)
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -2082,9 +2093,8 @@ 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user