fuse: add flag to turn on big writes

Prior to 2.6.26 fuse only supported single page write requests. In theory all
fuse filesystem should be able support bigger than 4k writes, as there's
nothing in the API to prevent it. Unfortunately there's a known case in
NTFS-3G where big writes cause filesystem corruption. There could also be
other filesystems, where the lack of testing with big write requests would
result in bugs.

To prevent such problems on a kernel upgrade, disable big writes by default,
but let filesystems set a flag to turn it on.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Szabolcs Szakacsits <szaka@ntfs-3g.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Miklos Szeredi and committed by Linus Torvalds 78bb6cb9 0f146a76

+10 -1
+2
fs/fuse/file.c
··· 804 804 if (offset == PAGE_CACHE_SIZE) 805 805 offset = 0; 806 806 807 + if (!fc->big_writes) 808 + break; 807 809 } while (iov_iter_count(ii) && count < fc->max_write && 808 810 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0); 809 811
+3
fs/fuse/fuse_i.h
··· 404 404 /** Is bmap not implemented by fs? */ 405 405 unsigned no_bmap : 1; 406 406 407 + /** Do multi-page cached writes */ 408 + unsigned big_writes : 1; 409 + 407 410 /** The number of requests waiting for completion */ 408 411 atomic_t num_waiting; 409 412
+4 -1
fs/fuse/inode.c
··· 576 576 fc->no_lock = 1; 577 577 if (arg->flags & FUSE_ATOMIC_O_TRUNC) 578 578 fc->atomic_o_trunc = 1; 579 + if (arg->flags & FUSE_BIG_WRITES) 580 + fc->big_writes = 1; 579 581 } else { 580 582 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 581 583 fc->no_lock = 1; ··· 601 599 arg->major = FUSE_KERNEL_VERSION; 602 600 arg->minor = FUSE_KERNEL_MINOR_VERSION; 603 601 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 604 - arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC; 602 + arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 603 + FUSE_BIG_WRITES; 605 604 req->in.h.opcode = FUSE_INIT; 606 605 req->in.numargs = 1; 607 606 req->in.args[0].size = sizeof(*arg);
+1
include/linux/fuse.h
··· 109 109 #define FUSE_POSIX_LOCKS (1 << 1) 110 110 #define FUSE_FILE_OPS (1 << 2) 111 111 #define FUSE_ATOMIC_O_TRUNC (1 << 3) 112 + #define FUSE_BIG_WRITES (1 << 5) 112 113 113 114 /** 114 115 * Release flags