summaryrefslogtreecommitdiffstats
path: root/fs (follow)
Commit message (Collapse)AuthorAgeFilesLines
* switch generic_write_checks() to iocb and iterAl Viro2015-04-1212-140/+79
| | | | | | | | | | | | ... returning -E... upon error and amount of data left in iter after (possible) truncation upon success. Note, that normal case gives a non-zero (positive) return value, so any tests for != 0 _must_ be updated. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Conflicts: fs/ext4/file.c
* ocfs2: move generic_write_checks() before the alignment checksAl Viro2015-04-121-24/+18
| | | | | | | | | | | | | Alignment checks for dio depend upon the range truncation done by generic_write_checks(). They can be done as soon as we got ocfs2_rw_lock() and that actually makes ocfs2_prepare_inode_for_write() simpler. The only thing to watch out for is restoring the original count in "unlock and redo without dio" case. Position doesn't need to be restored, since we change it only in O_APPEND case and in that case it will be reassigned anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ocfs2_file_write_iter: stop messing with pposAl Viro2015-04-121-12/+12
| | | | | | it's &iocb->ki_pos; no need to obfuscate. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Merge branch 'for-linus' into for-nextAl Viro2015-04-122-12/+25
|\
| * ocfs2: _really_ sync the right rangeAl Viro2015-04-091-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "ocfs2 syncs the wrong range" had been broken; prior to it the code was doing the wrong thing in case of O_APPEND, all right, but _after_ it we were syncing the wrong range in 100% cases. *ppos, aka iocb->ki_pos is incremented prior to that point, so we are always doing sync on the area _after_ the one we'd written to. Spotted by Joseph Qi <joseph.qi@huawei.com> back in January; unfortunately, I'd missed his mail back then ;-/ Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * ocfs2_file_write_iter: keep return value and current position update in syncAl Viro2015-04-081-1/+1
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * [regression] ocfs2: do *not* increment ->ki_pos twiceAl Viro2015-04-081-1/+0
| | | | | | | | | | | | | | generic_file_direct_write() already does that. Broken by "ocfs2: do not fallback to buffer I/O write if appending" Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * ioctx_alloc(): fix vma (and file) leak on failureAl Viro2015-04-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we fail past the aio_setup_ring(), we need to destroy the mapping. We don't need to care about anybody having found ctx, or added requests to it, since the last failure exit is exactly the failure to make ctx visible to lookups. Reproducer (based on one by Joe Mario <jmario@redhat.com>): void count(char *p) { char s[80]; printf("%s: ", p); fflush(stdout); sprintf(s, "/bin/cat /proc/%d/maps|/bin/fgrep -c '/[aio] (deleted)'", getpid()); system(s); } int main() { io_context_t *ctx; int created, limit, i, destroyed; FILE *f; count("before"); if ((f = fopen("/proc/sys/fs/aio-max-nr", "r")) == NULL) perror("opening aio-max-nr"); else if (fscanf(f, "%d", &limit) != 1) fprintf(stderr, "can't parse aio-max-nr\n"); else if ((ctx = calloc(limit, sizeof(io_context_t))) == NULL) perror("allocating aio_context_t array"); else { for (i = 0, created = 0; i < limit; i++) { if (io_setup(1000, ctx + created) == 0) created++; } for (i = 0, destroyed = 0; i < created; i++) if (io_destroy(ctx[i]) == 0) destroyed++; printf("created %d, failed %d, destroyed %d\n", created, limit - created, destroyed); count("after"); } } Found-by: Joe Mario <jmario@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * fix mremap() vs. ioctx_kill() raceAl Viro2015-04-061-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | teach ->mremap() method to return an error and have it fail for aio mappings in process of being killed Note that in case of ->mremap() failure we need to undo move_page_tables() we'd already done; we could call ->mremap() first, but then the failure of move_page_tables() would require undoing whatever _successful_ ->mremap() has done, which would be a lot more headache in general. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | udf_file_write_iter: reorder and simplifyAl Viro2015-04-121-20/+14
| | | | | | | | | | | | it's easier to do generic_write_checks() first Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | fuse: ->direct_IO() doesn't need generic_write_checks()Al Viro2015-04-121-8/+3
| | | | | | | | | | | | | | | | | | already done by caller. We used to call __fuse_direct_write(), which called generic_write_checks(); now the former got expanded, bringing the latter to the surface. It used to be called all along and calling it from there had been wrong all along... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | ext4_file_write_iter: move generic_write_checks() upAl Viro2015-04-121-19/+20
| | | | | | | | | | | | simpler that way... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | xfs_file_aio_write_checks: switch to iocb/iov_iterAl Viro2015-04-121-15/+16
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | generic_write_checks(): drop isblk argumentAl Viro2015-04-1212-16/+15
| | | | | | | | | | | | all remaining callers are passing 0; some just obscure that fact. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | blkdev_write_iter: expand generic_file_checks() call in thereAl Viro2015-04-121-6/+9
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | lift generic_write_checks() into callers of __generic_file_write_iter()Al Viro2015-04-124-19/+54
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | cifs: fold cifs_iovec_write() into the only callerAl Viro2015-04-121-31/+16
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | ntfs: move iov_iter_truncate() closer to generic_write_checks()Al Viro2015-04-121-52/+29
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | new_sync_write(): discard ->ki_pos unless the return value is positiveAl Viro2015-04-121-1/+2
| | | | | | | | | | | | | | | | | | That allows ->write_iter() instances much more convenient life wrt iocb->ki_pos (and fixes several filesystems with borderline POSIX violations when zero-length write succeeds and changes the current position). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | direct_IO: remove rw from a_ops->direct_IO()Omar Sandoval2015-04-1224-48/+33
| | | | | | | | | | | | | | Now that no one is using rw, remove it completely. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | direct_IO: use iov_iter_rw() instead of rw everywhereOmar Sandoval2015-04-1221-60/+60
| | | | | | | | | | | | | | | | | | | | | | The rw parameter to direct_IO is redundant with iov_iter->type, and treated slightly differently just about everywhere it's used: some users do rw & WRITE, and others do rw == WRITE where they should be doing a bitwise check. Simplify this with the new iov_iter_rw() helper, which always returns either READ or WRITE. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | Remove rw from dax_{do_,}io()Omar Sandoval2015-04-124-19/+18
| | | | | | | | | | | | | | And use iov_iter_rw() instead. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | Remove rw from {,__,do_}blockdev_direct_IO()Omar Sandoval2015-04-1219-64/+55
| | | | | | | | | | | | | | | | Most filesystems call through to these at some point, so we'll start here. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | ->aio_read and ->aio_write removedAl Viro2015-04-124-44/+6
| | | | | | | | | | | | no remaining users Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | kill do_sync_read/do_sync_writeAl Viro2015-04-121-38/+0
| | | | | | | | | | | | | | | | all remaining instances of aio_{read,write} (all 4 of them) have explicit ->read and ->write resp.; do_sync_read/do_sync_write is never called by __vfs_read/__vfs_write anymore and no other users had been left. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | fuse: use iov_iter_get_pages() for non-splice pathAl Viro2015-04-121-24/+17
| | | | | | | | | | | | store reference to iter instead of that to iovec Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | fuse: switch to ->read_iter/->write_iterAl Viro2015-04-121-12/+14
| | | | | | | | | | | | we just change the calling conventions here; more work to follow. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | make new_sync_{read,write}() staticAl Viro2015-04-1247-127/+2
| | | | | | | | | | | | | | | | All places outside of core VFS that checked ->read and ->write for being NULL or called the methods directly are gone now, so NULL {read,write} with non-NULL {read,write}_iter will do the right thing in all cases. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | coredump: accept any write methodAl Viro2015-04-121-1/+1
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | export __vfs_read()Al Viro2015-04-121-8/+5
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | autofs: switch to __vfs_write()Al Viro2015-04-122-2/+2
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | new helper: __vfs_write()Al Viro2015-04-121-12/+16
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | Merge branch '9p-iov_iter' into for-nextAl Viro2015-04-125-366/+139
|\ \
| * | 9p: we are leaking glock.client_id in v9fs_file_getlock()Al Viro2015-04-121-0/+2
| | | | | | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: switch to ->read_iter/->write_iterAl Viro2015-04-121-44/+39
| | | | | | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: get rid of v9fs_direct_file_read()Al Viro2015-04-122-51/+12
| | | | | | | | | | | | | | | | | | do it in ->direct_IO()... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: switch p9_client_read() to passing struct iov_iter *Al Viro2015-04-125-118/+46
| | | | | | | | | | | | | | | | | | ... and make it loop Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: get rid of v9fs_direct_file_write()Al Viro2015-04-122-82/+17
| | | | | | | | | | | | | | | | | | just handle it in ->direct_IO() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: fold v9fs_file_write_internal() into the callerAl Viro2015-04-122-49/+30
| | | | | | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: switch ->writepage() to direct use of p9_client_write()Al Viro2015-04-121-22/+13
| | | | | | | | | | | | | | | | | | Don't mess with kmap() - just use ITER_BVEC. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| * | 9p: switch p9_client_write() to passing it struct iov_iter *Al Viro2015-04-122-38/+18
| | | | | | | | | | | | | | | | | | ... and make it loop until it's done Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | | switch hugetlbfs to ->read_iter()Al Viro2015-04-121-58/+34
| | | | | | | | | | | | | | | | | | | | | ... and fix the case when the area we are asked to read crosses a hugepage boundary Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | | coda: switch to ->read_iter/->write_iterAl Viro2015-04-121-25/+15
| | | | | | | | | | | | | | | | | | | | | ... and request the same from the local cache - all filesystems with anything usable for that support those already. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | | ncpfs: switch to ->read_iter/->write_iterAl Viro2015-04-123-63/+37
|/ / | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | aio_run_iocb(): kill dead checkAl Viro2015-04-121-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We check if ->ki_pos is positive. However, by that point we have already done rw_verify_area(), which would have rejected such unless the file had been one of /dev/mem, /dev/kmem and /proc/kcore. All of which do not have vectored rw methods, so we would've bailed out even earlier. This check had been introduced before rw_verify_area() had been added there - in fact, it was a subset of checks done on sync paths by rw_verify_area() (back then the /dev/mem exception didn't exist at all). The rest of checks (mandatory locking, etc.) hadn't been added until later. Unfortunately, by the time the call of rw_verify_area() got added, the /dev/mem exception had already appeared, so it wasn't obvious that the older explicit check downstream had become dead code. It *is* a dead code, though, since the few files for which the exception applies do not have ->aio_{read,write}() or ->{read,write}_iter() and for them we won't reach that check anyway. What's more, even if we ever introduce vectored methods for /dev/mem and friends, they'll have to cope with negative positions anyway, since readv(2) and writev(2) are using the same checks as read(2) and write(2) - i.e. rw_verify_area(). Let's bury it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | ioctx_alloc(): remove pointless checkAl Viro2015-04-121-2/+1
| | | | | | | | | | | | | | | | | | | | Way, way back kiocb used to be picked from arrays, so ioctx_alloc() checked for multiplication overflow when calculating the size of such array. By the time fs/aio.c went into the tree (in 2002) they were already allocated one-by-one by kmem_cache_alloc(), so that check had already become pointless. Let's bury it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | expand __fuse_direct_write() in both callersAl Viro2015-04-121-25/+17
| | | | | | | | | | | | | | it's actually shorter that way *and* later we'll want iocb in scope of generic_write_check() caller. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | fuse: switch fuse_direct_io_file_operations to ->{read,write}_iter()Al Viro2015-04-121-17/+12
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | cuse: switch to iov_iterAl Viro2015-04-121-17/+10
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | Merge branch 'for-davem' into for-nextAl Viro2015-04-1221-62/+194
|\ \