[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJDppvHXW8rspmVx@kbusch-mbp>
Date: Mon, 4 Aug 2025 11:11:02 -0600
From: Keith Busch <kbusch@...nel.org>
To: Hannes Reinecke <hare@...e.de>
Cc: Keith Busch <kbusch@...a.com>, linux-block@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
snitzer@...nel.org, axboe@...nel.dk, dw@...idwei.uk,
brauner@...nel.org
Subject: Re: [PATCH 3/7] block: simplify direct io validity check
On Mon, Aug 04, 2025 at 08:55:36AM +0200, Hannes Reinecke wrote:
> On 8/2/25 01:47, Keith Busch wrote:
> > static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb,
> > struct iov_iter *iter)
> > {
> > - return iocb->ki_pos & (bdev_logical_block_size(bdev) - 1) ||
> > - !bdev_iter_is_aligned(bdev, iter);
> > + return (iocb->ki_pos | iov_iter_count(iter)) &
> > + (bdev_logical_block_size(bdev) - 1);
>
> Bitwise or? Sure?
Yep, this is correct. We need to return an error if either the size or
offset are not aligned to the block size. "Or"ing the two together gets
us a single check against the logical block size mask instead of doing
each individually.
Powered by blists - more mailing lists