Skip to content

Commit 9a8dbda

Browse files
johnpgarryaxboe
authored andcommitted
block/fs: Pass an iocb to generic_atomic_write_valid()
Darrick and Hannes both thought it better that generic_atomic_write_valid() should be passed a struct iocb, and not just the member of that struct which is referenced; see [0] and [1]. I think that makes a more generic and clean API, so make that change. [0] https://lore.kernel.org/linux-block/[email protected]/ [1] https://lore.kernel.org/linux-xfs/20240620212401.GA3058325@frogsfrogsfrogs/ Fixes: c34fc6f ("fs: Initial atomic write support") Suggested-by: Darrick J. Wong <[email protected]> Suggested-by: Hannes Reinecke <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 9852d85 commit 9a8dbda

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

block/fops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb)
3535
return opf;
3636
}
3737

38-
static bool blkdev_dio_invalid(struct block_device *bdev, loff_t pos,
38+
static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb,
3939
struct iov_iter *iter, bool is_atomic)
4040
{
41-
if (is_atomic && !generic_atomic_write_valid(iter, pos))
41+
if (is_atomic && !generic_atomic_write_valid(iocb, iter))
4242
return true;
4343

44-
return pos & (bdev_logical_block_size(bdev) - 1) ||
44+
return iocb->ki_pos & (bdev_logical_block_size(bdev) - 1) ||
4545
!bdev_iter_is_aligned(bdev, iter);
4646
}
4747

@@ -374,7 +374,7 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
374374
if (!iov_iter_count(iter))
375375
return 0;
376376

377-
if (blkdev_dio_invalid(bdev, iocb->ki_pos, iter, is_atomic))
377+
if (blkdev_dio_invalid(bdev, iocb, iter, is_atomic))
378378
return -EINVAL;
379379

380380
nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1);

fs/read_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out)
18301830
return 0;
18311831
}
18321832

1833-
bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos)
1833+
bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter)
18341834
{
18351835
size_t len = iov_iter_count(iter);
18361836

@@ -1840,7 +1840,7 @@ bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos)
18401840
if (!is_power_of_2(len))
18411841
return false;
18421842

1843-
if (!IS_ALIGNED(pos, len))
1843+
if (!IS_ALIGNED(iocb->ki_pos, len))
18441844
return false;
18451845

18461846
return true;

include/linux/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3721,6 +3721,6 @@ static inline bool vfs_empty_path(int dfd, const char __user *path)
37213721
return !c;
37223722
}
37233723

3724-
bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos);
3724+
bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter);
37253725

37263726
#endif /* _LINUX_FS_H */

0 commit comments

Comments
 (0)