aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus (follow)
AgeCommit message (Collapse)AuthorFilesLines
2010-12-16hfsplus: C99 comments clean-upAnton Salikhmetov3-13/+16
Match coding style restriction against C99 comments where checkpatch.pl reported errors about their usage. Signed-off-by: Anton Salikhmetov <alexo@tuxera.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-12-16hfsplus: over 80 character lines clean-upAnton Salikhmetov16-123/+260
Match coding style line length limitation where checkpatch.pl reported over-80-character-line warnings. Signed-off-by: Anton Salikhmetov <alexo@tuxera.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-12-16hfsplus: fix an artifact in ioctl flag checkingAnton Salikhmetov1-1/+1
Fix a flag checking artifact in hfsplus_ioctl_getflags() routine found while doing clean-up against assignments inside `if's. Signed-off-by: Anton Salikhmetov <alexo@tuxera.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: flush disk caches in sync and fsyncChristoph Hellwig4-0/+21
Flush the disk cache in fsync and sync to make sure data actually is on disk on completion of these system calls. There is a nobarrier mount option to disable this behaviour. It's slightly misnamed now that barrier actually are gone, but it matches the name used by all major filesystems. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: optimize fsyncChristoph Hellwig6-32/+78
Avoid doing unessecary work in fsync. Do nothing unless the inode was marked dirty, and only write the various metadata inodes out if they contain any dirty state from this inode. This is archived by adding three new dirty bits to the hfsplus-specific inode which are set in the correct places. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: split up inode flagsChristoph Hellwig4-19/+29
Split the flags field in the hfsplus inode into an extent_state flag that is locked by the extent_lock, and a new flags field that uses atomic bitops. The second will grow more flags in the next patch. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: write up fsync for directoriesChristoph Hellwig3-1/+3
fsync is supposed to not just work on regular files, but also on directories. Fortunately enough hfsplus_file_fsync works just fine for directories, so we can just wire it up. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: simplify fsyncChristoph Hellwig1-21/+20
Remove lots of code we don't need from fsync, we just need to call ->write_inode on the inode if it's dirty, for which sync_inode_metadata is a lot more efficient than write_inode_now, and we need to write out the various metadata inodes, which we now do explicitly instead of by calling ->sync_fs. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: avoid useless work in hfsplus_sync_fsChristoph Hellwig1-0/+3
There is no reason to write out the metadata inodes or volume headers during a non-blocking sync, as we are almost guaranteed to dirty them again during the inode writeouts. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: make sure sync writes out all metadataChristoph Hellwig1-1/+19
hfsplus stores all metadata except for the volume headers in special inodes. While these are marked hashed and periodically written out by the flusher threads, we can't rely on that for sync. For the case of a data integrity sync the VM has life-lock avoidance code that avoids writing inodes again that are redirtied during the sync, which is something that can happen easily for hfsplus. So make sure we explicitly write out the metadata inodes at the beginning of hfsplus_sync_fs. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: use raw bio access for partition tablesChristoph Hellwig2-70/+71
Switch the hfsplus partition table reding for cdroms to use our bio helpers. Again we don't rely on any caching in the buffer_heads, and this gets rid of the last buffer_head use in hfsplus. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: use raw bio access for the volume headersChristoph Hellwig3-88/+131
The hfsplus backup volume header is located two blocks from the end of the device. In case of device sizes that are not 4k aligned this means we can't access it using buffer_heads when using the default 4k block size. Switch to using raw bios to read/write all buffer headers. We were not relying on any caching behaviour of the buffer heads anyway. Additionally always read in the backup volume header during mount to verify that we can actually read it. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: always use hfsplus_sync_fs to write the volume headerChristoph Hellwig1-6/+3
Remove opencoded writing of the volume header in hfsplus_fill_super and hfsplus_put_super and offload it to hfsplus_sync_fs. In the put_super case this means we only write the superblock once instead of twice. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-23hfsplus: silence a few debug printksChristoph Hellwig4-5/+3
Turn a few noisy debug printks that show up during xfstests into complied out debug print statements. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-11-07hfsplus: fix option parsing during remountChristoph Hellwig3-5/+30
hfsplus only actually uses the force option during remount, but it uses the full option parser with a fake superblock to do so. This means remount will fail if any nls option is set (which happens frequently with older mount tools), even if it is the same. Fix this by adding a simpler version of the parser that only parses the force option for remount. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-29new helper: mount_bdev()Al Viro1-6/+4
... and switch of the obvious get_sb_bdev() users to ->mount() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-10-28Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/hfsplusLinus Torvalds2-2/+4
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/hfsplus: hfsplus: free space correcly for files unlinked while open hfsplus: fix double lock typo in ioctl
2010-10-27hfsplus: free space correcly for files unlinked while openChristoph Hellwig1-1/+3
hfsplus_delete_inode only truncates away all block allocations if i_nlink is zero. Make sure we properly drop the unlink count even when doing the rename hack for open but unlinked files. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-25new helper: ihold()Al Viro1-1/+1
Clones an existing reference to inode; caller must already hold one. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-10-25list.h: new helper - hlist_add_fake()Al Viro1-1/+1
Make node look as if it was on hlist, with hlist_del() working correctly. Usable without any locking... Convert a couple of places where we want to do that to inode->i_hash. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-10-25hfsplus: fix double lock typo in ioctlDan Carpenter1-1/+1
This was supposed to be a mutex_unlock() instead of a mutex_lock(). Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-15hfsplus: fix getxattr return valueChristoph Hellwig1-1/+1
We need to support -EOPNOTSUPP for attributes that are not supported to match other filesystems and allow userspace to detect if Posix ACLs are supported or not. setxattr already gets this right. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: remove the unused hfsplus_kmap/hfsplus_kunmap helpersChristoph Hellwig1-8/+0
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: create correct initial catalog entries for device filesChristoph Hellwig4-32/+18
Make sure the initial insertation of the catalog entry already contains the device number by calling init_special_inode early and setting writing out the dev field of the on-disk permission structure. The latter is facilitated by sharing the almost identical hfsplus_set_perms helpers between initial catalog entry creating and ->write_inode. Unless we crashed just after mknod this bug was harmless as the inode is marked dirty at the end of hfsplus_mknod, and hfsplus_write_inode will update the catalog entry to contain the correct value. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: remove superflous rootflags field in hfsplus_inode_infoChristoph Hellwig4-17/+12
The rootflags field in hfsplus_inode_info only caches the immutable and append-only flags in the VFS inode, so we can easily get rid of it. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: fix link corruptionChristoph Hellwig4-12/+18
HFS implements hardlink by using indirect catalog entries that refer to a hidden directly. The link target is cached in the dev field in the HFS+ specific inode, which is also used for the device number for device files, and inside for passing the nlink value of the indirect node from hfsplus_cat_write_inode to a helper function. Now if we happen to write out the indirect node while hfsplus_link is creating the catalog entry we'll get a link pointing to the linkid of the current nlink value. This can easily be reproduced by a large enough loop of local git-clone operations. Stop abusing the dev field in the HFS+ inode for short term storage by refactoring the way the permission structure in the catalog entry is set up, and rename the dev field to linkid to avoid any confusion. While we're at it also prevent creating hard links to special files, as the HFS+ dev and linkid share the same space in the on-disk structure. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: validate btree flagsChristoph Hellwig2-14/+20
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: handle more on-disk corruptions without oopsingEric Sandeen4-8/+48
hfs seems prone to bad things when it encounters on disk corruption. Many values are read from disk, and used as lengths to memcpy, as an example. This patch fixes up several of these problematic cases. o sanity check the on-disk maximum key lengths on mount (these are set to a defined value at mkfs time and shouldn't differ) o check on-disk node keylens against the maximum key length for each tree o fix hfs_btree_open so that going out via free_tree: doesn't wind up in hfs_releasepage, which wants to follow the very pointer we were trying to set up: HFS_SB(sb)->cat_tree = hfs_btree_open() . failure gets to hfs_releasepage and tries to follow HFS_SB(sb)->cat_tree Tested with the fsfuzzer; it survives more than it used to. [hch: ported of commit cf0594625083111ae522496dc1c256f7476939c2 from hfs] [hch: added the fixes from 5581d018ed3493d226e7a4d645d9c8a5af6c36b] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: hfs_bnode_find() can fail, resulting in hfs_bnode_split() breakageAl Viro1-3/+15
oops and fs corruption; the latter can happen even on valid fs in case of oom. [hch: port of commit 3d10a15d6919488204bdb264050d156ced20d9aa from hfs] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-14hfsplus: fix oops on mount with corrupted btree extent recordsJeff Mahoney1-2/+9
A particular fsfuzzer run caused an hfs file system to crash on mount. This is due to a corrupted MDB extent record causing a miscalculation of HFSPLUS_I(inode)->first_blocks for the extent tree. If the extent records are zereod out, then it won't trigger the first_blocks special case and instead falls through to the extent code, which we're in the middle of initializing. This patch catches the 0 size extent records, reports the corruption, and fails the mount. [hch: ported of commit 47f365eb575735c6b2edf5d08e0d16d26a9c23bd from hfs] Reported-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com> Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: fix rename over directoriesChristoph Hellwig1-1/+4
When renaming over a directory we need to use hfsplus_rmdir instead of hfsplus_unlink to evict the victim. This makes sure we properly error out on non-empty directory as required by Posix (BZ #16571), and it also makes sure we do the right thing in case i_nlink will every be set correctly for directories on hfsplus. Reported-by: Vlado Plaga <rechner@vlado-do.de> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: convert tree_lock to mutexThomas Gleixner3-4/+4
tree_lock is used as mutex so make it a mutex. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: add missing extent locking in hfsplus_write_inodeChristoph Hellwig2-15/+34
Most of the extent handling code already does proper SMP locking, but hfsplus_write_inode was calling into hfsplus_ext_write_extent without taking the extents_lock. Fix this by splitting hfsplus_ext_write_extent into an internal helper that expects the lock, and a public interface that first acquires it. Also add a few locking asserts and document the locking rules in hfsplus_fs.h. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: protect readdir against removals from open_dir_listChristoph Hellwig1-0/+2
We already have i_mutex for readdir and the namespace operations that add entries to open_dir_list, the only thing that was missing was the removal in hfsplus_dir_release. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: use atomic bitops for the superblock flagsChristoph Hellwig6-28/+30
The flags in the HFS+-specific superlock do get modified during runtime, use atomic bitops to make the modifications SMP safe. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: add per-superblock lock for volume header updatesChristoph Hellwig3-24/+50
Lock updates to the mutal fields in the volume header, and document the locing in the hfsplus_sb_info structure. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: remove the rsrc_inodes listChristoph Hellwig3-4/+9
We never walk the list - the only reason for it is to make the resource fork inodes appear hashed to the writeback code. Borrow a trick from JFS to do that without needing a list head. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: do not cache and write next_allocChristoph Hellwig2-3/+0
We never look at it, nor change the next_alloc field in the superblock. So don't bother caching it or writing it out in hfsplus_sync_fs. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: fix error handling in hfsplus_symlinkChristoph Hellwig1-14/+12
We need to free the inode again on a hfsplus_create_cat failure. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: merge mknod/mkdir/creatChristoph Hellwig1-48/+16
Make hfsplus_mkdir and hfsplus_create call hfsplus_mknod instead of duplicating the code. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: clean up hfsplus_write_inodeChristoph Hellwig1-43/+37
Add a new hfsplus_system_write_inode for writing the special system inodes and streamline the fastpath write_inode code. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: clean up hfsplus_igetChristoph Hellwig1-37/+40
Add a new hfsplus_system_read_inode for reading the special system inodes and streamline the fastpath iget code. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: fix HFSPLUS_I calling conventionChristoph Hellwig8-173/+193
HFSPLUS_I doesn't return a pointer to the hfsplus-specific inode information like all other FOO_I macros, but dereference the pointer in a way that made it look like a direct struct derefence. This only works as long as the HFSPLUS_I macro is used directly and prevents us from keepig a local hfsplus_inode_info pointer. Fix the calling convention and introduce a local hip variable in all functions that use it constantly. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: fix HFSPLUS_SB calling conventionChristoph Hellwig13-189/+209
HFSPLUS_SB doesn't return a pointer to the hfsplus-specific superblock information like all other FOO_SB macros, but dereference the pointer in a way that made it look like a direct struct derefence. This only works as long as the HFSPLUS_SB macro is used directly and prevents us from keepig a local hfsplus_sb_info pointer. Fix the calling convention and introduce a local sbi variable in all functions that use it constantly. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: remove BKL from hfsplus_put_superChristoph Hellwig1-5/+0
Except for ->put_super the BKL is now gone from HFS, which means it's superflous there too as ->put_super is serialized by the VFS. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: use alloc_mutex in hfsplus_sync_fsChristoph Hellwig1-2/+2
Use alloc_mutex to protect hfsplus_sync_fs against itself and concurrent allocations, which allows to get rid of lock_super in hfsplus. Note that most fields in the superblock still aren't protected against concurrent allocations, that will follow later. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: introduce alloc_mutexChristoph Hellwig3-4/+8
Use a new per-sb alloc_mutex instead of abusing i_mutex of the alloc_file to protect block allocations. This gets rid of lockdep nesting warnings and prepares for extending the scope of alloc_mutex. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: protect setflags using i_mutexChristoph Hellwig1-7/+8
Use i_mutex for protecting against concurrent setflags ioctls like in other filesystems and get rid of the BKL in hfsplus_ioctl. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: split hfsplus_ioctlChristoph Hellwig1-65/+80
Give each ioctl command a function of it's own. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
2010-10-01hfsplus: fix BKL leak in hfsplus_ioctlChristoph Hellwig1-2/+2
Currenly the HFSPLUS_IOC_EXT2_GETFLAGS case never unlocks the BKL, which can lead to easily reproduced lockups when doing multiple GETFLAGS ioctls. Fix this by only taking the BKL for the HFSPLUS_IOC_EXT2_SETFLAGS case as neither HFSPLUS_IOC_EXT2_GETFLAGS not the default error case needs it. Signed-off-by: Christoph Hellwig <hch@tuxera.com>