Merge tag 'erofs-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Dec 2022 04:14:04 +0000 (20:14 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Dec 2022 04:14:04 +0000 (20:14 -0800)
Pull erofs updates from Gao Xiang:
 "In this cycle, large folios are now enabled in the iomap/fscache mode
  for uncompressed files first. In order to do that, we've also cleaned
  up better interfaces between erofs and fscache, which are acked by
  fscache/netfs folks and included in this pull request.

  Other than that, there are random fixes around erofs over fscache and
  crafted images by syzbot, minor cleanups and documentation updates.

  Summary:

   - Enable large folios for iomap/fscache mode

   - Avoid sysfs warning due to mounting twice with the same fsid and
     domain_id in fscache mode

   - Refine fscache interface among erofs, fscache, and cachefiles

   - Use kmap_local_page() only for metabuf

   - Fixes around crafted images found by syzbot

   - Minor cleanups and documentation updates"

* tag 'erofs-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: validate the extent length for uncompressed pclusters
  erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails
  erofs: Fix pcluster memleak when its block address is zero
  erofs: use kmap_local_page() only for erofs_bread()
  erofs: enable large folios for fscache mode
  erofs: support large folios for fscache mode
  erofs: switch to prepare_ondemand_read() in fscache mode
  fscache,cachefiles: add prepare_ondemand_read() callback
  erofs: clean up cached I/O strategies
  erofs: update documentation
  erofs: check the uniqueness of fsid in shared domain in advance
  erofs: enable large folios for iomap mode

1  2 
fs/erofs/fscache.c
fs/erofs/inode.c

@@@ -159,47 -126,28 +126,28 @@@ static int erofs_fscache_read_folios_as
  
        ret = fscache_begin_read_operation(cres, cookie);
        if (ret)
-               goto out;
+               return ret;
  
        while (done < len) {
-               subreq = kzalloc(sizeof(struct netfs_io_subrequest),
-                                GFP_KERNEL);
-               if (subreq) {
-                       INIT_LIST_HEAD(&subreq->rreq_link);
-                       refcount_set(&subreq->ref, 2);
-                       subreq->rreq = rreq;
-                       refcount_inc(&rreq->ref);
-               } else {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-               subreq->start = pstart + done;
-               subreq->len     =  len - done;
-               subreq->flags = 1 << NETFS_SREQ_ONDEMAND;
+               loff_t sstart = pstart + done;
+               size_t slen = len - done;
+               unsigned long flags = 1 << NETFS_SREQ_ONDEMAND;
  
-               list_add_tail(&subreq->rreq_link, &rreq->subrequests);
-               source = cres->ops->prepare_read(subreq, LLONG_MAX);
-               if (WARN_ON(subreq->len == 0))
+               source = cres->ops->prepare_ondemand_read(cres,
+                               sstart, &slen, LLONG_MAX, &flags, 0);
+               if (WARN_ON(slen == 0))
                        source = NETFS_INVALID_READ;
                if (source != NETFS_READ_FROM_CACHE) {
-                       erofs_err(sb, "failed to fscache prepare_read (source %d)",
-                                 source);
-                       ret = -EIO;
-                       subreq->error = ret;
-                       erofs_fscache_put_subrequest(subreq);
-                       goto out;
+                       erofs_err(sb, "failed to fscache prepare_read (source %d)", source);
+                       return -EIO;
                }
  
-               atomic_inc(&rreq->nr_outstanding);
+               refcount_inc(&req->ref);
 -              iov_iter_xarray(&iter, READ, &req->mapping->i_pages,
++              iov_iter_xarray(&iter, ITER_DEST, &req->mapping->i_pages,
+                               lstart + done, slen);
  
-               iov_iter_xarray(&iter, ITER_DEST, &rreq->mapping->i_pages,
-                               start + done, subreq->len);
-               ret = fscache_read(cres, subreq->start, &iter,
-                                  NETFS_READ_HOLE_FAIL,
-                                  erofc_fscache_subreq_complete, subreq);
+               ret = fscache_read(cres, sstart, &iter, NETFS_READ_HOLE_FAIL,
+                                  erofs_fscache_subreq_complete, req);
                if (ret == -EIOCBQUEUED)
                        ret = 0;
                if (ret) {
@@@ -297,17 -233,19 +233,19 @@@ static int erofs_fscache_data_read_slic
                }
                iov_iter_zero(PAGE_SIZE - size, &iter);
                erofs_put_metabuf(&buf);
-               return PAGE_SIZE;
+               primary->submitted += PAGE_SIZE;
+               return 0;
        }
  
+       count = primary->len - primary->submitted;
        if (!(map.m_flags & EROFS_MAP_MAPPED)) {
-               count = len;
 -              iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count);
 +              iov_iter_xarray(&iter, ITER_DEST, &mapping->i_pages, pos, count);
                iov_iter_zero(count, &iter);
-               return count;
+               primary->submitted += count;
+               return 0;
        }
  
-       count = min_t(size_t, map.m_llen - (pos - map.m_la), len);
+       count = min_t(size_t, map.m_llen - (pos - map.m_la), count);
        DBG_BUGON(!count || count % PAGE_SIZE);
  
        mdev = (struct erofs_map_dev) {
Simple merge