summaryrefslogtreecommitdiffstats
path: root/fs/ufs/inode.c
Commit message (Collapse)AuthorAgeFilesLines
* ufs_iget(): fail with -ESTALE on deleted inodeAl Viro2017-06-171-13/+8
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fix signedness of timestamps on ufs1Al Viro2017-06-171-3/+3
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_truncate_blocks(): fix the case when size is in the last direct blockAl Viro2017-06-151-9/+12
| | | | | | | | | The logics when deciding whether we need to do anything with direct blocks is broken when new size is within the last direct block. It's better to find the path to the last byte _not_ to be removed and use that instead of the path to the beginning of the first block to be freed... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: avoid grabbing ->truncate_mutex if possibleAl Viro2017-06-151-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | tail unpacking is done in a wrong place; the deadlocks galore is best dealt with by doing that in ->write_iter() (and switching to iomap, while we are at it), but that's rather painful to backport. The trouble comes from grabbing pages that cover the beginning of tail from inside of ufs_new_fragments(); ongoing pageout of any of those is going to deadlock on ->truncate_mutex with process that got around to extending the tail holding that and waiting for page to get unlocked, while ->writepage() on that page is waiting on ->truncate_mutex. The thing is, we don't need ->truncate_mutex when the fragment we are trying to map is within the tail - the damn thing is allocated (tail can't contain holes). Let's do a plain lookup and if the fragment is present, we can just pretend that we'd won the race in almost all cases. The only exception is a fragment between the end of tail and the end of block containing tail. Protect ->i_lastfrag with ->meta_lock - read_seqlock_excl() is sufficient. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: we need to sync inode before freeing itAl Viro2017-06-101-0/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* excessive checks in ufs_write_failed() and ufs_evict_inode()Al Viro2017-06-091-13/+5
| | | | | | | | | | | As it is, short copy in write() to append-only file will fail to truncate the excessive allocated blocks. As the matter of fact, all checks in ufs_truncate_blocks() are either redundant or wrong for that caller. As for the only other caller (ufs_evict_inode()), we only need the file type checks there. Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_getfrag_block(): we only grab ->truncate_mutex on block creation pathAl Viro2017-06-091-1/+3
| | | | | Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_extend_tail(): fix the braino in calling conventions of ufs_new_fragments()Al Viro2017-06-091-1/+2
| | | | | | | | ... and it really needs splitting into "new" and "extend" cases, but that's for later Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: restore proper tail allocationAl Viro2017-06-091-1/+1
| | | | | Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Replace <asm/uaccess.h> with <linux/uaccess.h> globallyLinus Torvalds2016-12-241-1/+1
| | | | | | | | | | | | | This was entirely automated, using the script by Al: PATT='^[[:blank:]]*#[[:blank:]]*include[[:blank:]]*<asm/uaccess.h>' sed -i -e "s!$PATT!#include <linux/uaccess.h>!" \ $(git grep -l "$PATT"|grep -v ^include/linux/uaccess.h) to do the replacement at the end of the merge window. Requested-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* ufs: fix function declaration for ufs_truncate_blocksJeff Layton2016-12-221-1/+1
| | | | | | | | | | | sparse says: fs/ufs/inode.c:1195:6: warning: symbol 'ufs_truncate_blocks' was not declared. Should it be static? Note that the forward declaration in the file is already marked static. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* fs: Add helper to clean bdev aliases under a bh and use itJan Kara2016-11-041-2/+1
| | | | | | | | | | | Add a helper function that clears buffer heads from a block device aliasing passed bh. Use this helper function from filesystems instead of the original unmap_underlying_metadata() to save some boiler plate code and also have a better name for the functionalily since it is not unmapping anything for a *long* time. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
* Merge branch 'for-linus' of ↵Linus Torvalds2016-10-101-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull more vfs updates from Al Viro: ">rename2() work from Miklos + current_time() from Deepa" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fs: Replace current_fs_time() with current_time() fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps fs: Replace CURRENT_TIME with current_time() for inode timestamps fs: proc: Delete inode time initializations in proc_alloc_inode() vfs: Add current_time() api vfs: add note about i_op->rename changes to porting fs: rename "rename2" i_op to "rename" vfs: remove unused i_op->rename fs: make remaining filesystems use .rename2 libfs: support RENAME_NOREPLACE in simple_rename() fs: support RENAME_NOREPLACE for local filesystems ncpfs: fix unused variable warning
| * fs: Replace CURRENT_TIME_SEC with current_time() for inode timestampsDeepa Dinamani2016-09-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CURRENT_TIME_SEC is not y2038 safe. current_time() will be transitioned to use 64 bit time along with vfs in a separate patch. There is no plan to transistion CURRENT_TIME_SEC to use y2038 safe time interfaces. current_time() will also be extended to use superblock range checking parameters when range checking is introduced. This works because alloc_super() fills in the the s_time_gran in super block to NSEC_PER_SEC. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | fs: Give dentry to inode_change_ok() instead of inodeJan Kara2016-09-221-1/+1
|/ | | | | | | | | | | inode_change_ok() will be resposible for clearing capabilities and IMA extended attributes and as such will need dentry. Give it as an argument to inode_change_ok() instead of an inode. Also rename inode_change_ok() to setattr_prepare() to better relect that it does also some modifications in addition to checks. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
* mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macrosKirill A. Shutemov2016-04-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time ago with promise that one day it will be possible to implement page cache with bigger chunks than PAGE_SIZE. This promise never materialized. And unlikely will. We have many places where PAGE_CACHE_SIZE assumed to be equal to PAGE_SIZE. And it's constant source of confusion on whether PAGE_CACHE_* or PAGE_* constant should be used in a particular case, especially on the border between fs and mm. Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much breakage to be doable. Let's stop pretending that pages in page cache are special. They are not. The changes are pretty straight-forward: - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN}; - page_cache_get() -> get_page(); - page_cache_release() -> put_page(); This patch contains automated changes generated with coccinelle using script below. For some reason, coccinelle doesn't patch header files. I've called spatch for them manually. The only adjustment after coccinelle is revert of changes to PAGE_CAHCE_ALIGN definition: we are going to drop it later. There are few places in the code where coccinelle didn't reach. I'll fix them manually in a separate patch. Comments and documentation also will be addressed with the separate patch. virtual patch @@ expression E; @@ - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ expression E; @@ - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ @@ - PAGE_CACHE_SHIFT + PAGE_SHIFT @@ @@ - PAGE_CACHE_SIZE + PAGE_SIZE @@ @@ - PAGE_CACHE_MASK + PAGE_MASK @@ expression E; @@ - PAGE_CACHE_ALIGN(E) + PAGE_ALIGN(E) @@ expression E; @@ - page_cache_get(E) + get_page(E) @@ expression E; @@ - page_cache_release(E) + put_page(E) Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* don't put symlink bodies in pagecache into highmemAl Viro2015-12-081-0/+1
| | | | | | | | | | | | kmap() in page_follow_link_light() needed to go - allowing to hold an arbitrary number of kmaps for long is a great way to deadlocking the system. new helper (inode_nohighmem(inode)) needs to be used for pagecache symlinks inodes; done for all in-tree cases. page_follow_link_light() instrumented to yell about anything missed. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: get rid of ->setattr() for symlinksAl Viro2015-12-061-2/+2
| | | | | | | | | | | It was to needed for a couple of months in 2010, until UFS quota support got dropped. Since then it's equivalent to simple_setattr() (i.e. the default) for everything except the regular files. And dropping it there allows to convert all UFS symlinks to {page,simple}_symlink_inode_operations, getting rid of fs/ufs/symlink.c completely. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_get{frag,block}(): get rid of 'phys' argumentAl Viro2015-07-061-15/+8
| | | | | | | | | | | | | | | | Just pass NULL as locked_page in case of first block in the indirect chain. Old calling conventions aside, a reason for having 'phys' was that ufs_inode_getfrag() used to be able to do _two_ allocations - indirect block and extending/reallocating a tail. We needed locked_page for the latter (it's a data), but we also needed to figure out that indirect block is metadata. So we used to pass non-NULL locked_page in all cases *and* used NULL phys as indication of being asked to allocate an indirect. With tail unpacking taken into a separate function we don't need those convolutions anymore. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_getfrag_block(): tidy up a bitAl Viro2015-07-061-33/+15
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_getblock(): failure to read an indirect block is -EIOAl Viro2015-07-061-2/+3
| | | | | | ... and not "write to beginning of the disk", TYVM... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_getfrag_block(): turn following indirects into a loopAl Viro2015-07-061-24/+8
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_getfrag(): pass index instead of 'fragment'Al Viro2015-07-061-33/+17
| | | | | | same story as with ufs_inode_getblock() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_getfrag(): split extending the partial blocks offAl Viro2015-07-061-63/+65
| | | | | | ufs_extend_tail() is handling that now. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_getblock(): pass indirect block number and full indexAl Viro2015-07-061-46/+16
| | | | | | | ... instead of messing with buffer_head. We can bloody well do sb_bread() in there. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_getblock(): pass index instead of 'fragment'Al Viro2015-07-061-19/+13
| | | | | | | | | | | | | The value passed to ufs_inode_getblock() as the 3rd argument had lower bits ignored; the upper bits were shifted down and used and they actually make sense - those are _lower_ bits of index in indirect block (i.e. they form the index within a fragment within an indirect block). Pass those as argument. Upper bits of index (i.e. the number of fragment within indirect block) will join them shortly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_get{frag,block}(): leave sb_getblk() to callerAl Viro2015-07-061-33/+55
| | | | | | just return the damn block number Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_getfrag_block(): get rid of macro junglesAl Viro2015-07-061-29/+22
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_get{frag,block}(): consolidate success exitsAl Viro2015-07-061-28/+22
| | | | | | | | | | These calling conventions are rudiments of pre-2.3 times; they really need to be sanitized. This is the first step; next will be _always_ returning a block number, instead of this "return a pointer to buffer_head, except when we get to the actual data" crap. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: use the branch depth in ufs_getfrag_block()Al Viro2015-07-061-6/+4
| | | | | | we'd already calculated it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: move calculation of offsets into ufs_getfrag_block()Al Viro2015-07-061-8/+9
| | | | | | | | | ... and massage ufs_frag_map() to take those instead of fragment number. As it is, we duplicate the damn thing on the write side, open-coded and bloody hard to follow. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_inode_get{frag,block}(): get rid of retriesAl Viro2015-07-061-35/+8
| | | | | | | | | We are holding ->truncate_mutex, so nobody else can alter our block pointers. Rechecks/retries were needed back when we only held BKL there, and had to cope with write_begin/writepage and writepage/truncate races. Can't happen anymore... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* __ufs_truncate_blocks(): avoid excessive dirtying of indirect blocksAl Viro2015-07-061-3/+1
| | | | | | | | | | | | | | There's a case when an indirect block gets dirtied for no good reason - when there's a hole starting in the middle of area covered by it and spanning past its end, and truncate() is done precisely to the beginning of the hole. The block is obviously not modified at all - all removals happen beyond it. However, existing code ends up dirtying it just in case. It's trivial to fix and while it's not a real bug by any stretch of imagination, it makes the damn thing harder to follow. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* free_full_branch(): don't bother modifying the block we are going to freeAl Viro2015-07-061-12/+2
| | | | | | | Note that it's already made unreachable from the inode, so we don't have to worry about ufs_frag_map() walking into something already freed. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* move marking inode dirty to the end of __ufs_truncate_blocks()Al Viro2015-07-061-6/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* free_full_branch(): saner calling conventionsAl Viro2015-07-061-49/+51
| | | | | | | Have caller fetch the block number *and* remove it from wherever it was. Pass the block number instead. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_branch(): kill recursionAl Viro2015-07-061-26/+26
| | | | | | turn recursion into a pair of loops Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_branch(): massage towards killing recursionAl Viro2015-07-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | We always have 0 < depth2 <= depth in there, so if (--depth) { if (--depth2) A B } else { C // not using depth2 } D // not using depth2 is equivalent to if (--depth2) A with s/depth/depth - 1/ if (--depth) B else C D Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* split ufs_truncate_branch() into full- and partial-branch variantsAl Viro2015-07-061-16/+58
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs: unify the logics for collecting adjacent data blocks to freeAl Viro2015-07-061-34/+22
| | | | | | open-coded in several places... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_branch(): separate the calls with non-NULL offsetsAl Viro2015-07-061-4/+7
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_branch(): never call with offsets != NULL && depth2 == 0Al Viro2015-07-061-3/+6
| | | | | | | | | | For calls in __ufs_truncate_blocks() it's just a matter of not incrementing offsets[0] and not making that call - immediately following loop will be executed one extra time and we'll be just fine. For recursive call in ufs_trunc_branch() itself, just assing NULL to offsets if we would be about to make such call. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* __ufs_trunc_blocks(): turn the part after switch into a loopAl Viro2015-07-061-25/+10
| | | | | | | ... and turn the switch into if (), since all cases with depth != 1 have just become identical. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* __ufs_truncate_blocks(): unify freeing the full branchesAl Viro2015-07-061-15/+14
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* unify ufs_trunc_..indirect()Al Viro2015-07-061-138/+60
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_..indirect(): more massage towards unifyingAl Viro2015-07-061-17/+26
| | | | | | | | | | | | Instead of manually checking that the array contains only zeroes, find the position of the last non-zero (in __ufs_truncate(), where we can conveniently do that) and use that to tell if there's any non-zero in the array tail passed to ufs_trunc_...indirect(). The goal of all that clumsiness is to get fold these functions together. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_...indirect(): pass the array of indices instead of offsetsAl Viro2015-07-061-28/+22
| | | | | | | | rather than bitslicing the offset just formed as sum of shifted indices, pass the array of those indices itself. NULL is used as equivalent of "all zeroes" (== free the entire branch). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* __ufs_truncate(); find cutoff distances into branches by offsets[] arrayAl Viro2015-07-061-2/+6
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_dindirect(): pass the number of blocks to keepAl Viro2015-07-061-31/+26
| | | | | | same as the previous two. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ufs_trunc_indirect(): pass the index of the first pointer to freeAl Viro2015-07-061-33/+23
| | | | | | | ... instead of file offset. Same cleanups as in the tindirect conversion in previous commit. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>