forked from mirrors/linux
		
	 34310c442e
			
		
	
	
		34310c442e
		
	
	
	
	
		
			
			Add an io_uring command for encoded reads, using the same interface as the existing BTRFS_IOC_ENCODED_READ ioctl. btrfs_uring_encoded_read() is an io_uring version of btrfs_ioctl_encoded_read(), which validates the user input and calls btrfs_encoded_read() to read the appropriate metadata. If we determine that we need to read an extent from disk, we call btrfs_encoded_read_regular_fill_pages() through btrfs_uring_read_extent() to prepare the bio. The existing btrfs_encoded_read_regular_fill_pages() is changed so that if it is passed a valid uring_ctx, rather than waking up any waiting threads it calls btrfs_uring_read_extent_endio(). This in turn copies the read data back to userspace, and calls io_uring_cmd_done() to complete the io_uring command. Because we're potentially doing a non-blocking read, btrfs_uring_read_extent() doesn't clean up after itself if it returns -EIOCBQUEUED. Instead, it allocates a priv struct, populates the fields there that we will need to unlock the inode and free our allocations, and defers this to the btrfs_uring_read_finished() that gets called when the bio completes. Signed-off-by: Mark Harmstone <maharmstone@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			977 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			977 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0 */
 | |
| 
 | |
| #ifndef BTRFS_IOCTL_H
 | |
| #define BTRFS_IOCTL_H
 | |
| 
 | |
| #include <linux/types.h>
 | |
| 
 | |
| struct file;
 | |
| struct dentry;
 | |
| struct mnt_idmap;
 | |
| struct fileattr;
 | |
| struct btrfs_fs_info;
 | |
| struct btrfs_ioctl_balance_args;
 | |
| 
 | |
| long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 | |
| long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 | |
| int btrfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
 | |
| int btrfs_fileattr_set(struct mnt_idmap *idmap,
 | |
| 		       struct dentry *dentry, struct fileattr *fa);
 | |
| int btrfs_ioctl_get_supported_features(void __user *arg);
 | |
| void btrfs_sync_inode_flags_to_i_flags(struct inode *inode);
 | |
| int __pure btrfs_is_empty_uuid(const u8 *uuid);
 | |
| void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info,
 | |
| 				     struct btrfs_ioctl_balance_args *bargs);
 | |
| int btrfs_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags);
 | |
| void btrfs_uring_read_extent_endio(void *ctx, int err);
 | |
| 
 | |
| #endif
 |