[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d6386903-5c9c-4d11-9d7f-05b0981bdfea@oracle.com>
Date: Tue, 20 Feb 2024 09:52:40 +0000
From: John Garry <john.g.garry@...cle.com>
To: Dave Chinner <david@...morbit.com>
Cc: axboe@...nel.dk, kbusch@...nel.org, hch@....de, sagi@...mberg.me,
jejb@...ux.ibm.com, martin.petersen@...cle.com, djwong@...nel.org,
viro@...iv.linux.org.uk, brauner@...nel.org, dchinner@...hat.com,
jack@...e.cz, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-nvme@...ts.infradead.org,
linux-fsdevel@...r.kernel.org, tytso@....edu, jbongio@...gle.com,
linux-scsi@...r.kernel.org, ojaswin@...ux.ibm.com, linux-aio@...ck.org,
linux-btrfs@...r.kernel.org, io-uring@...r.kernel.org,
nilay@...ux.ibm.com, ritesh.list@...il.com,
Prasad Singamsetty <prasad.singamsetty@...cle.com>
Subject: Re: [PATCH v4 03/11] fs: Initial atomic write support
On 19/02/2024 22:44, Dave Chinner wrote:
> On Mon, Feb 19, 2024 at 01:01:01PM +0000, John Garry wrote:
>> @@ -3523,4 +3535,26 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
>> extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
>> int advice);
>>
>> +static inline bool atomic_write_valid(loff_t pos, struct iov_iter *iter,
>> + unsigned int unit_min, unsigned int unit_max)
>> +{
>> + size_t len = iov_iter_count(iter);
>> +
>> + if (!iter_is_ubuf(iter))
>> + return false;
>> +
>> + if (len == unit_min || len == unit_max) {
>> + /* ok if exactly min or max */
>> + } else if (len < unit_min || len > unit_max) {
>> + return false;
>> + } else if (!is_power_of_2(len)) {
>> + return false;
>> + }
> This doesn't need if else if else if and it doesn't need to check
> for exact unit min/max matches.
This is fastpath code, and I thought it quicker to just check if min/max
first. Based on recent discussions, for FS support I expect typically
len == unit_max.
But I can change to your simpler checking and later change to the
current method if those FS assumptions hold true.
> The exact matches require the
> length to be a power of 2, so the checks are simply:
>
> if (len < unit_min || len > unit_max)
> return false;
> if (!is_power_of_2(len))
> return false;
>
>> + if (pos & (len - 1))
>> + return false;
> This has typing issues - 64 bit value, 32 bit mask. probably should
> use:
>
> if (!IS_ALIGNED(pos, len))
> return false;
ok, good idea.
Thanks,
John
Powered by blists - more mailing lists