All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/30] Network fs helper library & fscache kiocb API
@ 2021-04-08 14:03 David Howells
  2021-04-08 14:04 ` [PATCH v6 01/30] iov_iter: Add ITER_XARRAY David Howells
                   ` (32 more replies)
  0 siblings, 33 replies; 71+ messages in thread
From: David Howells @ 2021-04-08 14:03 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Matthew Wilcox, linux-mm, linux-cifs, Alexander Viro,
	Mike Marshall, linux-afs, v9fs-developer, Linus Torvalds,
	Christoph Hellwig, Jeff Layton, linux-nfs, linux-cachefs,
	ceph-devel, Matthew Wilcox (Oracle),
	dhowells, Trond Myklebust, Anna Schumaker, Steve French,
	Dominique Martinet, Jeff Layton, David Wysochanski,
	Matthew Wilcox (Oracle),
	Alexander Viro, linux-cachefs, linux-afs, linux-nfs, linux-cifs,
	ceph-devel, v9fs-developer, linux-kernel, linux-mm


Here's a set of patches to do two things:

 (1) Add a helper library to handle the new VM readahead interface.  This
     is intended to be used unconditionally by the filesystem (whether or
     not caching is enabled) and provides a common framework for doing
     caching, transparent huge pages and, in the future, possibly fscrypt
     and read bandwidth maximisation.  It also allows the netfs and the
     cache to align, expand and slice up a read request from the VM in
     various ways; the netfs need only provide a function to read a stretch
     of data to the pagecache and the helper takes care of the rest.

 (2) Add an alternative fscache/cachfiles I/O API that uses the kiocb
     facility to do async DIO to transfer data to/from the netfs's pages,
     rather than using readpage with wait queue snooping on one side and
     vfs_write() on the other.  It also uses less memory, since it doesn't
     do buffered I/O on the backing file.

     Note that this uses SEEK_HOLE/SEEK_DATA to locate the data available
     to be read from the cache.  Whilst this is an improvement from the
     bmap interface, it still has a problem with regard to a modern
     extent-based filesystem inserting or removing bridging blocks of
     zeros.  Fixing that requires a much greater overhaul.

This is a step towards overhauling the fscache API.  The change is opt-in
on the part of the network filesystem.  A netfs should not try to mix the
old and the new API because of conflicting ways of handling pages and the
PG_fscache page flag and because it would be mixing DIO with buffered I/O.
Further, the helper library can't be used with the old API.

This does not change any of the fscache cookie handling APIs or the way
invalidation is done.

In the near term, I intend to deprecate and remove the old I/O API
(fscache_allocate_page{,s}(), fscache_read_or_alloc_page{,s}(),
fscache_write_page() and fscache_uncache_page()) and eventually replace
most of fscache/cachefiles with something simpler and easier to follow.

The patchset contains the following parts:

 (1) Some helper patches, including provision of an ITER_XARRAY iov
     iterator and a function to do readahead expansion.

 (2) Patches to add the netfs helper library.

 (3) A patch to add the fscache/cachefiles kiocb API.

 (4) Patches to add support in AFS for this.

Jeff Layton has patches to add support in Ceph for this.

With this, AFS without a cache passes all expected xfstests; with a cache,
there's an extra failure, but that's also there before these patches.
Fixing that probably requires a greater overhaul.  Ceph also passes the
expected tests.

The netfs lib and fscache/cachefiles patches can be found also on:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-lib

The afs patches can be found on:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=afs-netfs-lib


Changes
=======

ver #6:
      Merged in some fixes and added an additional tracepoint[8], including
      fixing the amalgamation of contiguous subrequests that are to be
      written to the cache.

      Added/merged some patches from Matthew Wilcox to make
      readahead_expand() appropriately adjust the trigger for the next
      readahead[9].  Also included is a patch to kerneldocify the
      file_ra_state struct.

      Altered netfs_write_begin() to use DEFINE_READAHEAD()[10].

      Split the afs patches out into their own branch.

ver #5:
      Fixed some review comments from Matthew Wilcox:

      - Put a comment into netfs_readahead() to indicate why there's a loop
        that puts, but doesn't unlock, "unconsumed" pages at the end when
        it could just return said pages to the caller to dispose of[6].
        (This is because where those pages are marked consumed).

      - Use the page_file_mapping() and page_index() helper functions
      	rather than accessing the page struct directly[6].

      - Better names for wrangling functions for PG_private_2 and
        PG_fscache wrangling functions[7].  Came up with
        {set,end,wait_for}_page_private_2() and aliased these for fscache.

      Moved the taking of/dropping a page ref for the PG_private_2 flag
      into the set and end functions.

ver #4:
      Fixed some review comments from Christoph Hellwig, including dropping
      the export of rw_verify_area()[3] and some minor stuff[4].

      Moved the declaration of readahead_expand() to a better location[5].

      Rebased to v5.12-rc2 and added a bunch of references into individual
      commits.

      Dropped Ceph support - that will go through the maintainer's tree.

      Added interface documentation for the netfs helper library.

ver #3:
      Rolled in the bug fixes.

      Adjusted the functions that unlock and wait for PG_fscache according
      to Linus's suggestion[1].

      Hold a ref on a page when PG_fscache is set as per Linus's
      suggestion[2].

      Dropped NFS support and added Ceph support.

ver #2:
      Fixed some bugs and added NFS support.

Link: https://lore.kernel.org/r/CAHk-=wh+2gbF7XEjYc=HV9w_2uVzVf7vs60BPz0gFA=+pUm3ww@mail.gmail.com/ [1]
Link: https://lore.kernel.org/r/CAHk-=wjgA-74ddehziVk=XAEMTKswPu1Yw4uaro1R3ibs27ztw@mail.gmail.com/ [2]
Link: https://lore.kernel.org/r/20210216102614.GA27555@lst.de/ [3]
Link: https://lore.kernel.org/r/20210216084230.GA23669@lst.de/ [4]
Link: https://lore.kernel.org/r/20210217161358.GM2858050@casper.infradead.org/ [5]
Link: https://lore.kernel.org/r/20210321014202.GF3420@casper.infradead.org/ [6]
Link: https://lore.kernel.org/r/20210321105309.GG3420@casper.infradead.org/ [7]
Link: https://lore.kernel.org/r/161781041339.463527.18139104281901492882.stgit@warthog.procyon.org.uk/ [8]
Link: https://lore.kernel.org/r/20210407201857.3582797-1-willy@infradead.org/ [9]
Link: https://lore.kernel.org/r/1234933.1617886271@warthog.procyon.org.uk/ [10]

References
==========

These patches have been published for review before, firstly as part of a
larger set:

Link: https://lore.kernel.org/r/158861203563.340223.7585359869938129395.stgit@warthog.procyon.org.uk/

Link: https://lore.kernel.org/r/159465766378.1376105.11619976251039287525.stgit@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/159465784033.1376674.18106463693989811037.stgit@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/159465821598.1377938.2046362270225008168.stgit@warthog.procyon.org.uk/

Link: https://lore.kernel.org/r/160588455242.3465195.3214733858273019178.stgit@warthog.procyon.org.uk/

Then as a cut-down set:

Link: https://lore.kernel.org/r/161118128472.1232039.11746799833066425131.stgit@warthog.procyon.org.uk/ # v1

Link: https://lore.kernel.org/r/161161025063.2537118.2009249444682241405.stgit@warthog.procyon.org.uk/ # v2

Link: https://lore.kernel.org/r/161340385320.1303470.2392622971006879777.stgit@warthog.procyon.org.uk/ # v3

Link: https://lore.kernel.org/r/161539526152.286939.8589700175877370401.stgit@warthog.procyon.org.uk/ # v4

Link: https://lore.kernel.org/r/161653784755.2770958.11820491619308713741.stgit@warthog.procyon.org.uk/ # v5

Proposals/information about the design has been published here:

Link: https://lore.kernel.org/r/24942.1573667720@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/2758811.1610621106@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/1441311.1598547738@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/160655.1611012999@warthog.procyon.org.uk/

And requests for information:

Link: https://lore.kernel.org/r/3326.1579019665@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/4467.1579020509@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/3577430.1579705075@warthog.procyon.org.uk/

I've posted partial patches to try and help 9p and cifs along:

Link: https://lore.kernel.org/r/1514086.1605697347@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/1794123.1605713481@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/241017.1612263863@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/270998.1612265397@warthog.procyon.org.uk/

David
---
David Howells (28):
      iov_iter: Add ITER_XARRAY
      mm: Add set/end/wait functions for PG_private_2
      mm: Implement readahead_control pageset expansion
      netfs: Make a netfs helper module
      netfs: Documentation for helper library
      netfs, mm: Move PG_fscache helper funcs to linux/netfs.h
      netfs, mm: Add set/end/wait_on_page_fscache() aliases
      netfs: Provide readahead and readpage netfs helpers
      netfs: Add tracepoints
      netfs: Gather stats
      netfs: Add write_begin helper
      netfs: Define an interface to talk to a cache
      netfs: Add a tracepoint to log failures that would be otherwise unseen
      fscache, cachefiles: Add alternate API to use kiocb for read/write to cache
      afs: Disable use of the fscache I/O routines
      afs: Pass page into dirty region helpers to provide THP size
      afs: Print the operation debug_id when logging an unexpected data version
      afs: Move key to afs_read struct
      afs: Don't truncate iter during data fetch
      afs: Log remote unmarshalling errors
      afs: Set up the iov_iter before calling afs_extract_data()
      afs: Use ITER_XARRAY for writing
      afs: Wait on PG_fscache before modifying/releasing a page
      afs: Extract writeback extension into its own function
      afs: Prepare for use of THPs
      afs: Use the fs operation ops to handle FetchData completion
      afs: Use new netfs lib read helper API
      afs: Use the netfs_write_begin() helper

Matthew Wilcox (Oracle) (2):
      mm/filemap: Pass the file_ra_state in the ractl
      fs: Document file_ra_state


 Documentation/filesystems/index.rst         |    1 +
 Documentation/filesystems/netfs_library.rst |  526 ++++++++
 fs/Kconfig                                  |    1 +
 fs/Makefile                                 |    1 +
 fs/afs/Kconfig                              |    1 +
 fs/afs/dir.c                                |  225 ++--
 fs/afs/file.c                               |  483 ++------
 fs/afs/fs_operation.c                       |    4 +-
 fs/afs/fsclient.c                           |  108 +-
 fs/afs/inode.c                              |    7 +-
 fs/afs/internal.h                           |   59 +-
 fs/afs/rxrpc.c                              |  150 +--
 fs/afs/write.c                              |  657 +++++-----
 fs/afs/yfsclient.c                          |   82 +-
 fs/cachefiles/Makefile                      |    1 +
 fs/cachefiles/interface.c                   |    5 +-
 fs/cachefiles/internal.h                    |    9 +
 fs/cachefiles/io.c                          |  420 +++++++
 fs/ext4/verity.c                            |    2 +-
 fs/f2fs/file.c                              |    2 +-
 fs/f2fs/verity.c                            |    2 +-
 fs/fscache/Kconfig                          |    1 +
 fs/fscache/Makefile                         |    1 +
 fs/fscache/internal.h                       |    4 +
 fs/fscache/io.c                             |  116 ++
 fs/fscache/page.c                           |    2 +-
 fs/fscache/stats.c                          |    1 +
 fs/netfs/Kconfig                            |   23 +
 fs/netfs/Makefile                           |    5 +
 fs/netfs/internal.h                         |   97 ++
 fs/netfs/read_helper.c                      | 1185 +++++++++++++++++++
 fs/netfs/stats.c                            |   59 +
 include/linux/fs.h                          |   24 +-
 include/linux/fscache-cache.h               |    4 +
 include/linux/fscache.h                     |   50 +-
 include/linux/netfs.h                       |  234 ++++
 include/linux/pagemap.h                     |   41 +-
 include/net/af_rxrpc.h                      |    2 +-
 include/trace/events/afs.h                  |   74 +-
 include/trace/events/netfs.h                |  261 ++++
 mm/filemap.c                                |   63 +-
 mm/internal.h                               |    7 +-
 mm/readahead.c                              |   97 +-
 net/rxrpc/recvmsg.c                         |    9 +-
 44 files changed, 3998 insertions(+), 1108 deletions(-)
 create mode 100644 Documentation/filesystems/netfs_library.rst
 create mode 100644 fs/cachefiles/io.c
 create mode 100644 fs/fscache/io.c
 create mode 100644 fs/netfs/Kconfig
 create mode 100644 fs/netfs/Makefile
 create mode 100644 fs/netfs/internal.h
 create mode 100644 fs/netfs/read_helper.c
 create mode 100644 fs/netfs/stats.c
 create mode 100644 include/linux/netfs.h
 create mode 100644 include/trace/events/netfs.h



^ permalink raw reply	[flat|nested] 71+ messages in thread
* Re: [RFC PATCH 2/2] iov_iter: Drop the X argument from iterate_all_kinds() and use B instead
@ 2021-04-09 23:38 kernel test robot
  0 siblings, 0 replies; 71+ messages in thread
From: kernel test robot @ 2021-04-09 23:38 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 18625 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <161799186664.847742.14555840742293852768.stgit@warthog.procyon.org.uk>
References: <161799186664.847742.14555840742293852768.stgit@warthog.procyon.org.uk>
TO: David Howells <dhowells@redhat.com>

Hi David,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on next-20210409]
[cannot apply to linus/master v5.12-rc6 v5.12-rc5 v5.12-rc4 v5.12-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-Howells/iov_iter-Remove-iov_iter_for_each_range/20210410-021151
base:    e99d8a8495175df8cb8b739f8cf9b0fc9d0cd3b5
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: microblaze-randconfig-s031-20210409 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-279-g6d5d9b42-dirty
        # https://github.com/0day-ci/linux/commit/3a86123438f2aac6764901c8462752f378c958c0
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review David-Howells/iov_iter-Remove-iov_iter_for_each_range/20210410-021151
        git checkout 3a86123438f2aac6764901c8462752f378c958c0
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> lib/iov_iter.c:1481:9: sparse: sparse: context imbalance in 'iov_iter_get_pages' - different lock contexts for basic block
>> lib/iov_iter.c:1607:9: sparse: sparse: context imbalance in 'iov_iter_get_pages_alloc' - different lock contexts for basic block
   lib/iov_iter.c: note: in included file:
   include/net/checksum.h:31:39: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected restricted __wsum [usertype] sum @@     got unsigned int @@
   include/net/checksum.h:31:39: sparse:     expected restricted __wsum [usertype] sum
   include/net/checksum.h:31:39: sparse:     got unsigned int
   include/net/checksum.h:39:45: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected restricted __wsum [usertype] sum @@     got unsigned int @@
   include/net/checksum.h:39:45: sparse:     expected restricted __wsum [usertype] sum
   include/net/checksum.h:39:45: sparse:     got unsigned int
>> lib/iov_iter.c:1818:5: sparse: sparse: context imbalance in 'iov_iter_npages' - different lock contexts for basic block

vim +/iov_iter_get_pages +1481 lib/iov_iter.c

788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1480  
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04 @1481  ssize_t iov_iter_get_pages(struct iov_iter *i,
2c80929c4c4d54 mm/iov_iter.c  Miklos Szeredi 2014-09-24  1482  		   struct page **pages, size_t maxsize, unsigned maxpages,
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1483  		   size_t *start)
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1484  {
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1485  	if (maxsize > i->count)
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1486  		maxsize = i->count;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1487  
00e23707442a75 lib/iov_iter.c David Howells  2018-10-22  1488  	if (unlikely(iov_iter_is_pipe(i)))
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1489  		return pipe_get_pages(i, pages, maxsize, maxpages, start);
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1490  	if (unlikely(iov_iter_is_xarray(i)))
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1491  		return iter_xarray_get_pages(i, pages, maxsize, maxpages, start);
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1492  	if (unlikely(iov_iter_is_discard(i)))
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1493  		return -EFAULT;
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1494  
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1495  	iterate_all_kinds(i, maxsize, v, ({
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1496  		unsigned long addr = (unsigned long)v.iov_base;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1497  		size_t len = v.iov_len + (*start = addr & (PAGE_SIZE - 1));
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1498  		int n;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1499  		int res;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1500  
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1501  		if (len > maxpages * PAGE_SIZE)
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1502  			len = maxpages * PAGE_SIZE;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1503  		addr &= ~(PAGE_SIZE - 1);
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1504  		n = DIV_ROUND_UP(len, PAGE_SIZE);
73b0140bf0fe9d lib/iov_iter.c Ira Weiny      2019-05-13  1505  		res = get_user_pages_fast(addr, n,
73b0140bf0fe9d lib/iov_iter.c Ira Weiny      2019-05-13  1506  				iov_iter_rw(i) != WRITE ?  FOLL_WRITE : 0,
73b0140bf0fe9d lib/iov_iter.c Ira Weiny      2019-05-13  1507  				pages);
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1508  		if (unlikely(res < 0))
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1509  			return res;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1510  		return (res == n ? len : res * PAGE_SIZE) - *start;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1511  	0;}),({
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1512  		/* can't be more than PAGE_SIZE */
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1513  		*start = v.bv_offset;
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1514  		get_page(*pages = v.bv_page);
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1515  		return v.bv_len;
a280455fa87053 mm/iov_iter.c  Al Viro        2014-11-27  1516  	}),({
a280455fa87053 mm/iov_iter.c  Al Viro        2014-11-27  1517  		return -EFAULT;
3a86123438f2aa lib/iov_iter.c David Howells  2021-04-09  1518  	})
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1519  	)
e5393fae3b49e8 mm/iov_iter.c  Al Viro        2014-11-27  1520  	return 0;
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1521  }
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1522  EXPORT_SYMBOL(iov_iter_get_pages);
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1523  
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1524  static struct page **get_pages_array(size_t n)
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1525  {
752ade68cbd81d lib/iov_iter.c Michal Hocko   2017-05-08  1526  	return kvmalloc_array(n, sizeof(struct page *), GFP_KERNEL);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1527  }
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1528  
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1529  static ssize_t pipe_get_pages_alloc(struct iov_iter *i,
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1530  		   struct page ***pages, size_t maxsize,
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1531  		   size_t *start)
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1532  {
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1533  	struct page **p;
8cefc107ca54c8 lib/iov_iter.c David Howells  2019-11-15  1534  	unsigned int iter_head, npages;
d7760d638b140d lib/iov_iter.c Ilya Dryomov   2018-05-02  1535  	ssize_t n;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1536  
33844e665104b1 lib/iov_iter.c Al Viro        2016-12-21  1537  	if (!maxsize)
33844e665104b1 lib/iov_iter.c Al Viro        2016-12-21  1538  		return 0;
33844e665104b1 lib/iov_iter.c Al Viro        2016-12-21  1539  
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1540  	if (!sanity(i))
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1541  		return -EFAULT;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1542  
8cefc107ca54c8 lib/iov_iter.c David Howells  2019-11-15  1543  	data_start(i, &iter_head, start);
8cefc107ca54c8 lib/iov_iter.c David Howells  2019-11-15  1544  	/* Amount of free space: some of this one + all after this one */
8cefc107ca54c8 lib/iov_iter.c David Howells  2019-11-15  1545  	npages = pipe_space_for_user(iter_head, i->pipe->tail, i->pipe);
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1546  	n = npages * PAGE_SIZE - *start;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1547  	if (maxsize > n)
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1548  		maxsize = n;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1549  	else
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1550  		npages = DIV_ROUND_UP(maxsize + *start, PAGE_SIZE);
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1551  	p = get_pages_array(npages);
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1552  	if (!p)
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1553  		return -ENOMEM;
8cefc107ca54c8 lib/iov_iter.c David Howells  2019-11-15  1554  	n = __pipe_get_pages(i, maxsize, p, iter_head, start);
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1555  	if (n > 0)
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1556  		*pages = p;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1557  	else
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1558  		kvfree(p);
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1559  	return n;
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1560  }
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1561  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1562  static ssize_t iter_xarray_get_pages_alloc(struct iov_iter *i,
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1563  					   struct page ***pages, size_t maxsize,
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1564  					   size_t *_start_offset)
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1565  {
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1566  	struct page **p;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1567  	unsigned nr, offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1568  	pgoff_t index, count;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1569  	size_t size = maxsize, actual;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1570  	loff_t pos;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1571  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1572  	if (!size)
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1573  		return 0;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1574  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1575  	pos = i->xarray_start + i->iov_offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1576  	index = pos >> PAGE_SHIFT;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1577  	offset = pos & ~PAGE_MASK;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1578  	*_start_offset = offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1579  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1580  	count = 1;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1581  	if (size > PAGE_SIZE - offset) {
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1582  		size -= PAGE_SIZE - offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1583  		count += size >> PAGE_SHIFT;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1584  		size &= ~PAGE_MASK;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1585  		if (size)
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1586  			count++;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1587  	}
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1588  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1589  	p = get_pages_array(count);
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1590  	if (!p)
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1591  		return -ENOMEM;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1592  	*pages = p;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1593  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1594  	nr = iter_xarray_copy_pages(p, i->xarray, index, count);
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1595  	if (nr == 0)
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1596  		return 0;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1597  
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1598  	actual = PAGE_SIZE * nr;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1599  	actual -= offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1600  	if (nr == count && size > 0) {
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1601  		unsigned last_offset = (nr > 1) ? 0 : offset;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1602  		actual -= PAGE_SIZE - (last_offset + size);
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1603  	}
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1604  	return actual;
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1605  }
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1606  
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04 @1607  ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1608  		   struct page ***pages, size_t maxsize,
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1609  		   size_t *start)
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1610  {
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1611  	struct page **p;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1612  
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1613  	if (maxsize > i->count)
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1614  		maxsize = i->count;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1615  
00e23707442a75 lib/iov_iter.c David Howells  2018-10-22  1616  	if (unlikely(iov_iter_is_pipe(i)))
241699cd72a848 lib/iov_iter.c Al Viro        2016-09-22  1617  		return pipe_get_pages_alloc(i, pages, maxsize, start);
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1618  	if (unlikely(iov_iter_is_xarray(i)))
788abcfb66c10d lib/iov_iter.c David Howells  2020-02-10  1619  		return iter_xarray_get_pages_alloc(i, pages, maxsize, start);
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1620  	if (unlikely(iov_iter_is_discard(i)))
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1621  		return -EFAULT;
9ea9ce0427aab0 lib/iov_iter.c David Howells  2018-10-20  1622  
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1623  	iterate_all_kinds(i, maxsize, v, ({
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1624  		unsigned long addr = (unsigned long)v.iov_base;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1625  		size_t len = v.iov_len + (*start = addr & (PAGE_SIZE - 1));
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1626  		int n;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1627  		int res;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1628  
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1629  		addr &= ~(PAGE_SIZE - 1);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1630  		n = DIV_ROUND_UP(len, PAGE_SIZE);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1631  		p = get_pages_array(n);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1632  		if (!p)
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1633  			return -ENOMEM;
73b0140bf0fe9d lib/iov_iter.c Ira Weiny      2019-05-13  1634  		res = get_user_pages_fast(addr, n,
73b0140bf0fe9d lib/iov_iter.c Ira Weiny      2019-05-13  1635  				iov_iter_rw(i) != WRITE ?  FOLL_WRITE : 0, p);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1636  		if (unlikely(res < 0)) {
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1637  			kvfree(p);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1638  			return res;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1639  		}
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1640  		*pages = p;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1641  		return (res == n ? len : res * PAGE_SIZE) - *start;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1642  	0;}),({
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1643  		/* can't be more than PAGE_SIZE */
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1644  		*start = v.bv_offset;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1645  		*pages = p = get_pages_array(1);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1646  		if (!p)
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1647  			return -ENOMEM;
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1648  		get_page(*p = v.bv_page);
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1649  		return v.bv_len;
a280455fa87053 mm/iov_iter.c  Al Viro        2014-11-27  1650  	}),({
a280455fa87053 mm/iov_iter.c  Al Viro        2014-11-27  1651  		return -EFAULT;
3a86123438f2aa lib/iov_iter.c David Howells  2021-04-09  1652  	})
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1653  	)
1b17f1f2e56a09 mm/iov_iter.c  Al Viro        2014-11-27  1654  	return 0;
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1655  }
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1656  EXPORT_SYMBOL(iov_iter_get_pages_alloc);
62a8067a7f35db mm/iov_iter.c  Al Viro        2014-04-04  1657  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29816 bytes --]

^ permalink raw reply	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2021-04-22 14:51 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 14:03 [PATCH v6 00/30] Network fs helper library & fscache kiocb API David Howells
2021-04-08 14:04 ` [PATCH v6 01/30] iov_iter: Add ITER_XARRAY David Howells
2021-04-09  1:24   ` Al Viro
2021-04-09 18:10     ` [RFC PATCH 1/2] iov_iter: Remove iov_iter_for_each_range() David Howells
2021-04-09 18:11     ` [RFC PATCH 2/2] iov_iter: Drop the X argument from iterate_all_kinds() and use B instead David Howells
2021-04-09  9:09   ` [PATCH v6 01/30] iov_iter: Add ITER_XARRAY David Howells
2021-04-09 11:44     ` Matthew Wilcox
2021-04-22 13:35   ` Jeff Layton
2021-04-22 13:35     ` Jeff Layton
2021-04-22 13:51   ` David Howells
2021-04-22 14:51     ` Jeff Layton
2021-04-22 14:51       ` Jeff Layton
2021-04-08 14:04 ` [PATCH v6 02/30] mm: Add set/end/wait functions for PG_private_2 David Howells
2021-04-08 14:50   ` Matthew Wilcox
2021-04-08 15:25   ` David Howells
2021-04-08 15:57   ` David Howells
2021-04-08 21:15   ` [RFC][PATCH] mm: Split page_has_private() in two to better handle PG_private_2 David Howells
2021-04-08 23:50     ` Linus Torvalds
2021-04-08 23:50       ` Linus Torvalds
2021-04-09 10:59       ` [RFC PATCH 1/3] Make the generic bitops return bool David Howells
2021-04-09 10:59       ` [RFC PATCH 2/3] mm: Return bool from pagebit test functions David Howells
2021-04-09 11:16         ` Matthew Wilcox
2021-04-09 12:00         ` David Howells
2021-04-09 12:35         ` David Howells
2021-04-09 16:03         ` David Howells
2021-04-09 16:03           ` David Howells
2021-04-09 10:59       ` [RFC PATCH 3/3] mm: Split page_has_private() in two to better handle PG_private_2 David Howells
2021-04-09 11:24         ` Matthew Wilcox
2021-04-09  2:25     ` [RFC][PATCH] " kernel test robot
2021-04-09  8:14     ` David Howells
2021-04-09 19:01     ` kernel test robot
2021-04-13 15:11   ` [PATCH v7] mm: Add set/end/wait functions for PG_private_2 David Howells
2021-04-13 15:22     ` Matthew Wilcox
2021-04-08 14:04 ` [PATCH v6 03/30] mm/filemap: Pass the file_ra_state in the ractl David Howells
2021-04-08 14:04 ` [PATCH v6 04/30] fs: Document file_ra_state David Howells
2021-04-08 14:04 ` [PATCH v6 05/30] mm: Implement readahead_control pageset expansion David Howells
2021-04-08 14:55   ` Matthew Wilcox
2021-04-08 14:05 ` [PATCH v6 06/30] netfs: Make a netfs helper module David Howells
2021-04-08 14:05 ` [PATCH v6 07/30] netfs: Documentation for helper library David Howells
2021-04-08 14:05 ` [PATCH v6 08/30] netfs, mm: Move PG_fscache helper funcs to linux/netfs.h David Howells
2021-04-08 14:05 ` [PATCH v6 09/30] netfs, mm: Add set/end/wait_on_page_fscache() aliases David Howells
2021-04-08 14:06 ` [PATCH v6 10/30] netfs: Provide readahead and readpage netfs helpers David Howells
2021-04-08 14:06 ` [PATCH v6 11/30] netfs: Add tracepoints David Howells
2021-04-08 14:06 ` [PATCH v6 12/30] netfs: Gather stats David Howells
2021-04-08 14:06 ` [PATCH v6 13/30] netfs: Add write_begin helper David Howells
2021-04-08 14:06 ` [PATCH v6 14/30] netfs: Define an interface to talk to a cache David Howells
2021-04-08 14:07 ` [PATCH v6 15/30] netfs: Add a tracepoint to log failures that would be otherwise unseen David Howells
2021-04-08 14:07 ` [PATCH v6 16/30] fscache, cachefiles: Add alternate API to use kiocb for read/write to cache David Howells
2021-04-08 14:07 ` [PATCH v6 17/30] afs: Disable use of the fscache I/O routines David Howells
2021-04-08 14:07 ` [PATCH v6 18/30] afs: Pass page into dirty region helpers to provide THP size David Howells
2021-04-08 14:08 ` [PATCH v6 19/30] afs: Print the operation debug_id when logging an unexpected data version David Howells
2021-04-08 14:08 ` [PATCH v6 20/30] afs: Move key to afs_read struct David Howells
2021-04-08 14:08 ` [PATCH v6 21/30] afs: Don't truncate iter during data fetch David Howells
2021-04-08 14:08 ` [PATCH v6 22/30] afs: Log remote unmarshalling errors David Howells
2021-04-08 14:08 ` [PATCH v6 23/30] afs: Set up the iov_iter before calling afs_extract_data() David Howells
2021-04-08 14:09 ` [PATCH v6 24/30] afs: Use ITER_XARRAY for writing David Howells
2021-04-08 14:09 ` [PATCH v6 25/30] afs: Wait on PG_fscache before modifying/releasing a page David Howells
2021-04-08 14:09 ` [PATCH v6 26/30] afs: Extract writeback extension into its own function David Howells
2021-04-08 14:09 ` [PATCH v6 27/30] afs: Prepare for use of THPs David Howells
2021-04-08 14:09 ` [PATCH v6 28/30] afs: Use the fs operation ops to handle FetchData completion David Howells
2021-04-08 14:10 ` [PATCH v6 29/30] afs: Use new netfs lib read helper API David Howells
2021-04-08 14:10 ` [PATCH v6 30/30] afs: Use the netfs_write_begin() helper David Howells
2021-04-08 15:40 ` [PATCH v6 00/30] Network fs helper library & fscache kiocb API Jeff Layton
2021-04-08 15:40   ` Jeff Layton
2021-04-09 12:04 ` David Wysochanski
2021-04-09 12:04   ` David Wysochanski
2021-04-13 14:56   ` David Wysochanski
2021-04-13 14:56     ` David Wysochanski
2021-04-13 16:21 ` Marc Dionne
2021-04-13 16:21   ` Marc Dionne
2021-04-09 23:38 [RFC PATCH 2/2] iov_iter: Drop the X argument from iterate_all_kinds() and use B instead kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.