bcachefs: Fix failure to return error on misaligned dio write
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 29 May 2024 20:28:41 +0000 (16:28 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 29 May 2024 20:40:30 +0000 (16:40 -0400)
This was reported as an error when running coreutils shred.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io-direct.c

index 09d21aef879af89bbdadbfabcc71bc630604e069..049b61bc9a5b38e491c367d9a6b5a0f9c6567426 100644 (file)
@@ -609,8 +609,10 @@ ssize_t bch2_direct_write(struct kiocb *req, struct iov_iter *iter)
        if (unlikely(ret))
                goto err_put_write_ref;
 
-       if (unlikely((req->ki_pos|iter->count) & (block_bytes(c) - 1)))
+       if (unlikely((req->ki_pos|iter->count) & (block_bytes(c) - 1))) {
+               ret = -EINVAL;
                goto err_put_write_ref;
+       }
 
        inode_dio_begin(&inode->v);
        bch2_pagecache_block_get(inode);