[PATCH 1/2] mtd: rawnand: nandsim: use a NOFS scope for cache file I/O
Tal Zussman
tz2294 at columbia.edu
Wed Oct 14 20:24:58 PDT 2026
nandsim reads and writes its cache file from inside MTD operations,
which the filesystem on top of it can issue from writeback, so an
allocation in that path must not recurse into filesystem reclaim. The
driver ensures that by running kernel_read() and kernel_write() under
PF_MEMALLOC, which is more than it needs. Use memalloc_nofs_save()
instead.
Signed-off-by: Tal Zussman <tz2294 at columbia.edu>
---
drivers/mtd/nand/raw/nandsim.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index fe968037f75a..4559df2cfa3c 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -1342,14 +1342,14 @@ static ssize_t ns_read_file(struct nandsim *ns, struct file *file, void *buf,
{
ssize_t tx;
int err;
- unsigned int noreclaim_flag;
+ unsigned int nofs_flag;
err = ns_get_pages(ns, file, count, pos);
if (err)
return err;
- noreclaim_flag = memalloc_noreclaim_save();
+ nofs_flag = memalloc_nofs_save();
tx = kernel_read(file, buf, count, &pos);
- memalloc_noreclaim_restore(noreclaim_flag);
+ memalloc_nofs_restore(nofs_flag);
ns_put_pages(ns);
return tx;
}
@@ -1359,14 +1359,14 @@ static ssize_t ns_write_file(struct nandsim *ns, struct file *file, void *buf,
{
ssize_t tx;
int err;
- unsigned int noreclaim_flag;
+ unsigned int nofs_flag;
err = ns_get_pages(ns, file, count, pos);
if (err)
return err;
- noreclaim_flag = memalloc_noreclaim_save();
+ nofs_flag = memalloc_nofs_save();
tx = kernel_write(file, buf, count, &pos);
- memalloc_noreclaim_restore(noreclaim_flag);
+ memalloc_nofs_restore(nofs_flag);
ns_put_pages(ns);
return tx;
}
--
2.39.5
More information about the linux-mtd
mailing list