Re: [PATCH 2/2] fsx: add support for RWF_DONTCACHE

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On 1/7/25 4:22 PM, Darrick J. Wong wrote:
> On Tue, Jan 07, 2025 at 11:24:13AM -0700, Jens Axboe wrote:
>> On 1/7/25 11:19 AM, Darrick J. Wong wrote:
>>> On Tue, Jan 07, 2025 at 09:05:15AM -0700, Jens Axboe wrote:
>>>> Using RWF_DONTCACHE tells the kernel that any page cache instantiated
>>>> by this operation should get pruned once the operation completes. If
>>>> data is in cache prior to the operation it will remain there.
>>>>
>>>> Add ops for testing both the read and write side of this. At startup,
>>>> kernel support for this feature is probed. If support isn't available,
>>>> uncached/dontcache IO is performed as regular buffered IO. If -Z is
>>>> used to turn on O_DIRECT, then uncached/dontcache IO isn't performed.
>>>
>>> Huh.  Does the kernel reject RWF_DONTCACHE for directio?  And, if a
>>
>> It doesn't, it simply ignores it. Not sure why you ask? It's buffered IO
>> after all, falling back to just clearing the flag seems like the most
>> sensible solution here.
> 
> I was curious, because your code does has_dontcache=0 when -Z is used to
> select directio mode.  So I wondered if it that was because the kernel
> would return EOPNOTSUPP for directio + RWF_DONTCACHE? :)

Ah gotcha - no that's not the case, it's just that it doesn't make any
sense to open a file O_DIRECT and then use RWF_DONTCACHE, when it
already shouldn't be cached. Outside of the case you brought up where
we'd want to drop page cache for O_DIRECT that ends up allocating page
cache, but that should be done regardless imho.

> Then I wondered if there was actually a good usecase either for letting
> userspace specify it, or for filesystems to add it for buffered write
> fallback.  At this point I would wager there's a stronger case for
> adding drop-behind automatically because userspace shouldn't have to
> communicate "write this without accessing the page cache, and don't
> leave file contents in the page cache that I already told you not to
> do."

Yeah agree, I think we should just use the same mechanism for O_DIRECT
instantiated page cache, without needing the app setting RWF_DONTCACHE.
O_DIRECT is also slowed down by the existence of page cache, which can
be annoying particularly when you fill a file with O_DIRECT and now have
a bunch of page cache for it.

> Anyway the fstests change satisfies me now so
> Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>

Thanks!

-- 
Jens Axboe




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux