Re: [PATCH v6 03/34] iov_iter: Pass I/O direction into iov_iter_get_pages*()

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

 



Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:

> On Mon, Jan 16, 2023 at 11:08:24PM +0000, David Howells wrote:
> > Define FOLL_SOURCE_BUF and FOLL_DEST_BUF to indicate to get_user_pages*()
> > and iov_iter_get_pages*() how the buffer is intended to be used in an I/O
> > operation.  Don't use READ and WRITE as a read I/O writes to memory and
> > vice versa - which causes confusion.
> > 
> > The direction is checked against the iterator's data_source.
> 
> Why can't we use the existing FOLL_WRITE?

Because FOLL_WRITE doesn't mean the same as WRITE:

 (1) It looks like it should really be FOLL_CHECK_PTES_WRITABLE.  It's not
     defined as being anything to do with the I/O.

 (2) The reason Al added ITER_SOURCE and ITER_DEST is that the use of READ and
     WRITE with the iterators is confusing and kind of inverted - and the same
     would apply with using FOLL_WRITE:

	if (rw == READ)
		gup_flags |= FOLL_WRITE;

So my thought is to make how you are using the buffer described by the
iterator explicit: "I'm using it as a source buffer" or "I'm using it as a
destination buffer".

Also, I don't want it to be FOLL_WRITE or 0.  I want it to be written
explicitly in both cases.  If you're going to insist on using FOLL_WRITE, then
there should be a FOLL_READ to go with it, even if it's #defined to 0.

David




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux