From ad83d07f62a79e7725d31b41d3f0316526a83634 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 13 Jul 2004 20:23:03 +0000 Subject: [PATCH] fix minor bug --- ChangeLog | 5 ++++- kernel/file.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4198f9..95d0e2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ 2004-07-13 Miklos Szeredi * Add FUSE_HARD_REMOVE flag, and '-i' option to fuse main, which - disable the "hide if open" behavior of unlink/rename. + disable the "hide if open" behavior of unlink/rename. + + * If temporary buffer allocation fails in raw read, fall back to a + smaller buffer 2004-07-12 Miklos Szeredi diff --git a/kernel/file.c b/kernel/file.c index 215d9b5..8e32f45 100644 --- a/kernel/file.c +++ b/kernel/file.c @@ -345,14 +345,20 @@ static ssize_t fuse_read(struct file *file, char *buf, size_t count, char *tmpbuf; ssize_t res = 0; loff_t pos = *ppos; + unsigned int max_read = count < fc->max_read ? count : fc->max_read; - tmpbuf = kmalloc(count < fc->max_read ? count : fc->max_read, - GFP_KERNEL); + do { + tmpbuf = kmalloc(max_read, GFP_KERNEL); + if (tmpbuf) + break; + + max_read /= 2; + } while (max_read > PAGE_CACHE_SIZE / 4); if (!tmpbuf) return -ENOMEM; while (count) { - size_t nbytes = count < fc->max_read ? count : fc->max_read; + size_t nbytes = count < max_read ? count : max_read; ssize_t res1; res1 = fuse_send_read(inode, tmpbuf, pos, nbytes); if (res1 < 0) { -- 2.30.2