mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 05:26:07 +00:00
fuse fixes for 6.13-rc7
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSQHSd0lITzzeNWNm3h3BK/laaZPAUCZ3vEzQAKCRDh3BK/laaZ PK9jAP9AvwPhO+0ySnPbQ+eupfYV4+NmUhk01SBXAhlHlA31AQD9E7tbrWapFQ4K +TqVBCKSX4b8QSUwtNCq3yw43+ts0Aw= =72uv -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZ309+QAKCRCRxhvAZXjc otnUAP9kaerhNRAaEHN60FWo2OyOs0RwGZCtTheAbuFeVryt9QD/UAtlKLETKHN0 BZVIsgxE/Rl9uzjSHAjBAPw905Yqiw4= =r3Ee -----END PGP SIGNATURE----- Merge tag 'fuse-fixes-6.13-rc7' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse Pull fuse fixes from Miklos Szeredi <mszeredi@redhat.com>: - Fix fuse_get_user_pages() allocation failure handling. - Fix direct-io folio offset and length calculation. * tag 'fuse-fixes-6.13-rc7' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: Set *nbytesp=0 in fuse_get_user_pages on allocation failure fuse: fix direct io folio offset and length calculation Link: https://lore.kernel.org/r/CAJfpegu7o_X%3DSBWk_C47dUVUQ1mJZDEGe1MfD0N3wVJoUBWdmg@mail.gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
commit
3ff93c5935
@ -1541,8 +1541,10 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
|
||||
*/
|
||||
struct page **pages = kzalloc(max_pages * sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
if (!pages)
|
||||
return -ENOMEM;
|
||||
if (!pages) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (nbytes < *nbytesp && nr_pages < max_pages) {
|
||||
unsigned nfolios, i;
|
||||
@ -1557,18 +1559,22 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
|
||||
|
||||
nbytes += ret;
|
||||
|
||||
ret += start;
|
||||
/* Currently, all folios in FUSE are one page */
|
||||
nfolios = DIV_ROUND_UP(ret, PAGE_SIZE);
|
||||
nfolios = DIV_ROUND_UP(ret + start, PAGE_SIZE);
|
||||
|
||||
ap->descs[ap->num_folios].offset = start;
|
||||
fuse_folio_descs_length_init(ap->descs, ap->num_folios, nfolios);
|
||||
for (i = 0; i < nfolios; i++)
|
||||
ap->folios[i + ap->num_folios] = page_folio(pages[i]);
|
||||
for (i = 0; i < nfolios; i++) {
|
||||
struct folio *folio = page_folio(pages[i]);
|
||||
unsigned int offset = start +
|
||||
(folio_page_idx(folio, pages[i]) << PAGE_SHIFT);
|
||||
unsigned int len = min_t(unsigned int, ret, PAGE_SIZE - start);
|
||||
|
||||
ap->descs[ap->num_folios].offset = offset;
|
||||
ap->descs[ap->num_folios].length = len;
|
||||
ap->folios[ap->num_folios] = folio;
|
||||
start = 0;
|
||||
ret -= len;
|
||||
ap->num_folios++;
|
||||
}
|
||||
|
||||
ap->num_folios += nfolios;
|
||||
ap->descs[ap->num_folios - 1].length -=
|
||||
(PAGE_SIZE - ret) & (PAGE_SIZE - 1);
|
||||
nr_pages += nfolios;
|
||||
}
|
||||
kfree(pages);
|
||||
@ -1584,6 +1590,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
|
||||
else
|
||||
ap->args.out_pages = true;
|
||||
|
||||
out:
|
||||
*nbytesp = nbytes;
|
||||
|
||||
return ret < 0 ? ret : 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user