Commit 4aa571d6 authored by David Howells's avatar David Howells Committed by Christian Brauner

cifs: Don't support ITER_XARRAY

There's now no need to support ITER_XARRAY in cifs as netfslib hands down
ITER_FOLIOQ instead - and that's simpler to use with iterate_and_advance()
as it doesn't hold the RCU read lock over the step function.

This is part of the process of phasing out ITER_XARRAY.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Tom Talpey <tom@talpey.com>
cc: Enzo Matsumiya <ematsumiya@suse.de>
cc: linux-cifs@vger.kernel.org
Link: https://lore.kernel.org/r/20240814203850.2240469-26-dhowells@redhat.com/ # v2
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent a2906d33
...@@ -25,54 +25,6 @@ ...@@ -25,54 +25,6 @@
#include "../common/arc4.h" #include "../common/arc4.h"
#include <crypto/aead.h> #include <crypto/aead.h>
/*
* Hash data from an XARRAY-type iterator.
*/
static ssize_t cifs_shash_xarray(const struct iov_iter *iter, ssize_t maxsize,
struct shash_desc *shash)
{
struct folio *folios[16], *folio;
unsigned int nr, i, j, npages;
loff_t start = iter->xarray_start + iter->iov_offset;
pgoff_t last, index = start / PAGE_SIZE;
ssize_t ret = 0;
size_t len, offset, foffset;
void *p;
if (maxsize == 0)
return 0;
last = (start + maxsize - 1) / PAGE_SIZE;
do {
nr = xa_extract(iter->xarray, (void **)folios, index, last,
ARRAY_SIZE(folios), XA_PRESENT);
if (nr == 0)
return -EIO;
for (i = 0; i < nr; i++) {
folio = folios[i];
npages = folio_nr_pages(folio);
foffset = start - folio_pos(folio);
offset = foffset % PAGE_SIZE;
for (j = foffset / PAGE_SIZE; j < npages; j++) {
len = min_t(size_t, maxsize, PAGE_SIZE - offset);
p = kmap_local_page(folio_page(folio, j));
ret = crypto_shash_update(shash, p, len);
kunmap_local(p);
if (ret < 0)
return ret;
maxsize -= len;
if (maxsize <= 0)
return 0;
start += len;
offset = 0;
index++;
}
}
} while (nr == ARRAY_SIZE(folios));
return 0;
}
static size_t cifs_shash_step(void *iter_base, size_t progress, size_t len, static size_t cifs_shash_step(void *iter_base, size_t progress, size_t len,
void *priv, void *priv2) void *priv, void *priv2)
{ {
...@@ -96,9 +48,6 @@ static int cifs_shash_iter(const struct iov_iter *iter, size_t maxsize, ...@@ -96,9 +48,6 @@ static int cifs_shash_iter(const struct iov_iter *iter, size_t maxsize,
struct iov_iter tmp_iter = *iter; struct iov_iter tmp_iter = *iter;
int err = -EIO; int err = -EIO;
if (iov_iter_type(iter) == ITER_XARRAY)
return cifs_shash_xarray(iter, maxsize, shash);
if (iterate_and_advance_kernel(&tmp_iter, maxsize, shash, &err, if (iterate_and_advance_kernel(&tmp_iter, maxsize, shash, &err,
cifs_shash_step) != maxsize) cifs_shash_step) != maxsize)
return err; return err;
......
...@@ -2584,52 +2584,6 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter, ...@@ -2584,52 +2584,6 @@ static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter,
return ret; return ret;
} }
/*
* Extract folio fragments from an XARRAY-class iterator and add them to an
* RDMA list. The folios are not pinned.
*/
static ssize_t smb_extract_xarray_to_rdma(struct iov_iter *iter,
struct smb_extract_to_rdma *rdma,
ssize_t maxsize)
{
struct xarray *xa = iter->xarray;
struct folio *folio;
loff_t start = iter->xarray_start + iter->iov_offset;
pgoff_t index = start / PAGE_SIZE;
ssize_t ret = 0;
size_t off, len;
XA_STATE(xas, xa, index);
rcu_read_lock();
xas_for_each(&xas, folio, ULONG_MAX) {
if (xas_retry(&xas, folio))
continue;
if (WARN_ON(xa_is_value(folio)))
break;
if (WARN_ON(folio_test_hugetlb(folio)))
break;
off = offset_in_folio(folio, start);
len = min_t(size_t, maxsize, folio_size(folio) - off);
if (!smb_set_sge(rdma, folio_page(folio, 0), off, len)) {
rcu_read_unlock();
return -EIO;
}
maxsize -= len;
ret += len;
if (rdma->nr_sge >= rdma->max_sge || maxsize <= 0)
break;
}
rcu_read_unlock();
if (ret > 0)
iov_iter_advance(iter, ret);
return ret;
}
/* /*
* Extract page fragments from up to the given amount of the source iterator * Extract page fragments from up to the given amount of the source iterator
* and build up an RDMA list that refers to all of those bits. The RDMA list * and build up an RDMA list that refers to all of those bits. The RDMA list
...@@ -2657,9 +2611,6 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len, ...@@ -2657,9 +2611,6 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,
case ITER_FOLIOQ: case ITER_FOLIOQ:
ret = smb_extract_folioq_to_rdma(iter, rdma, len); ret = smb_extract_folioq_to_rdma(iter, rdma, len);
break; break;
case ITER_XARRAY:
ret = smb_extract_xarray_to_rdma(iter, rdma, len);
break;
default: default:
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
return -EIO; return -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment