Thread (45 messages) 45 messages, 3 authors, 2021-08-23

Re: [PATCH v10 02/14] fs: export variant of generic_write_checks without iov_iter

From: Omar Sandoval <osandov@osandov.com>
Date: 2021-08-20 17:31:41
Also in: linux-btrfs, linux-fsdevel

On Fri, Aug 20, 2021 at 10:59:28AM +0300, Nikolay Borisov wrote:

On 18.08.21 г. 0:06, Omar Sandoval wrote:
quoted
From: Omar Sandoval <redacted>

Encoded I/O in Btrfs needs to check a write with a given logical size
without an iov_iter that matches that size (because the iov_iter we have
is for the compressed data). So, factor out the parts of
generic_write_check() that expect an iov_iter into a new
__generic_write_checks() function and export that.

Signed-off-by: Omar Sandoval <redacted>
---
 fs/read_write.c    | 40 ++++++++++++++++++++++------------------
 include/linux/fs.h |  1 +
 2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 0029ff2b0ca8..3bddd5ee7f64 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1633,6 +1633,26 @@ int generic_write_check_limits(struct file *file, loff_t pos, loff_t *count)
 	return 0;
 }
 
+/* Like generic_write_checks(), but takes size of write instead of iter. */
+int __generic_write_checks(struct kiocb *iocb, loff_t *count)
+{
+	struct file *file = iocb->ki_filp;
+	struct inode *inode = file->f_mapping->host;
+
+	if (IS_SWAPFILE(inode))
+		return -ETXTBSY;
 Missing 'if(!count) return 0' from original code ?
Good catch, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help