fix minor bug
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 13 Jul 2004 20:23:03 +0000 (20:23 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Tue, 13 Jul 2004 20:23:03 +0000 (20:23 +0000)
ChangeLog
kernel/file.c

index e4198f9445dfa8fddd3b533482ddd81f11250092..95d0e2cd082d7db3a6bcd5f977bcc48be2bb9e2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
 2004-07-13  Miklos Szeredi <miklos@szeredi.hu>
 
        * 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 <miklos@szeredi.hu>
 
index 215d9b5331baea18c229ec033b88d955052b863d..8e32f45928195c78a14144cccd94a99e8172f9ea 100644 (file)
@@ -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) {