]> git.karo-electronics.de Git - linux-beck.git/log
linux-beck.git
11 years agoxfs: check LSN ordering for v5 superblocks during recovery
Dave Chinner [Wed, 28 Aug 2013 11:22:47 +0000 (21:22 +1000)]
xfs: check LSN ordering for v5 superblocks during recovery

Log recovery has some strict ordering requirements which unordered
or reordered metadata writeback can defeat. This can occur when an
item is logged in a transaction, written back to disk, and then
logged in a new transaction before the tail of the log is moved past
the original modification.

The result of this is that when we read an object off disk for
recovery purposes, the buffer that we read may not contain the
object type that recovery is expecting and hence at the end of the
checkpoint being recovered we have an invalid object in memory.

This isn't usually a problem, as recovery will then replay all the
other checkpoints and that brings the object back to a valid and
correct state, but the issue is that while the object is in the
invalid state it can be flushed to disk. This results in the object
verifier failing and triggering a corruption shutdown of log
recover. This is correct behaviour for the verifiers - the problem
is that we are not detecting that the object we've read off disk is
newer than the transaction we are replaying.

All metadata in v5 filesystems has the LSN of it's last modification
stamped in it. This enabled log recover to read that field and
determine the age of the object on disk correctly. If the LSN of the
object on disk is older than the transaction being replayed, then we
replay the modification. If the LSN of the object matches or is more
recent than the transaction's LSN, then we should avoid overwriting
the object as that is what leads to the transient corrupt state.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: btree block LSN escaping to disk uninitialised
Dave Chinner [Wed, 28 Aug 2013 11:22:46 +0000 (21:22 +1000)]
xfs: btree block LSN escaping to disk uninitialised

When testing LSN ordering code for v5 superblocks, it was discovered
that the the LSN embedded in the generic btree blocks was
occasionally uninitialised. These values didn't get written to disk
by metadata writeback - they got written by previous transactions in
log recovery.

The issue is here that the when the block is first allocated and
initialised, the LSN field was not initialised - it gets overwritten
before IO is issued on the buffer - but the value that is logged by
transactions that modify the header before it is written to disk
(and initialised) contain garbage. Hence the first recovery of the
buffer will stamp garbage into the LSN field, and that can cause
subsequent transactions to not replay correctly.

The fix is simply to initialise the bb_lsn field to zero when we
initialise the block for the first time.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoXFS: Assertion failed: first <= last && last < BBTOB(bp->b_length), file: fs/xfs...
Dave Chinner [Mon, 26 Aug 2013 04:13:30 +0000 (14:13 +1000)]
XFS: Assertion failed: first <= last && last < BBTOB(bp->b_length), file: fs/xfs/xfs_trans_buf.c, line: 568

The calculation doesn't take into account the size of the dir v3
header, so overestimates the hash entries in a node. This causes
directory buffer overruns when splitting and merging nodes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Tested-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix bad dquot buffer size in log recovery readahead
Dave Chinner [Tue, 27 Aug 2013 03:25:43 +0000 (13:25 +1000)]
xfs: fix bad dquot buffer size in log recovery readahead

xfstests xfs/087 fails 100% reliably with this assert:

XFS (vdb): Mounting Filesystem
XFS (vdb): Starting recovery (logdev: internal)
XFS: Assertion failed: bp->b_flags & XBF_STALE, file: fs/xfs/xfs_buf.c, line: 548

while trying to read a dquot buffer in xlog_recover_dquot_ra_pass2().

The issue is that the buffer length to read that is passed to
xfs_buf_readahead is in units of filesystem blocks, not disk blocks.
(i.e. FSB, not daddr). Fix it but putting the correct conversion in
place.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: don't account buffer cancellation during log recovery readahead
Dave Chinner [Mon, 26 Aug 2013 22:10:53 +0000 (08:10 +1000)]
xfs: don't account buffer cancellation during log recovery readahead

When doing readhaead in log recovery, we check to see if buffers are
cancelled before doing readahead. If we find a cancelled buffer,
however, we always decrement the reference count we have on it, and
that means that readahead is causing a double decrement of the
cancelled buffer reference count.

This results in log recovery *replaying cancelled buffers* as the
actual recovery pass does not find the cancelled buffer entry in the
commit phase of the second pass across a transaction. On debug
kernels, this results in an ASSERT failure like so:

XFS: Assertion failed: !(flags & XFS_BLF_CANCEL), file: fs/xfs/xfs_log_recover.c, line: 1815

xfstests generic/311 reproduces this ASSERT failure with 100%
reproducability.

Fix it by making readahead only peek at the buffer cancelled state
rather than the full accounting that xlog_check_buffer_cancelled()
does.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: check for underflow in xfs_iformat_fork()
Dan Carpenter [Thu, 15 Aug 2013 05:53:38 +0000 (08:53 +0300)]
xfs: check for underflow in xfs_iformat_fork()

The "di_size" variable comes from the disk and it's a signed 64 bit.
We check the upper limit but we should check for negative numbers as
well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: xfs_dir3_sfe_put_ino can be static
Fengguang Wu [Sat, 24 Aug 2013 00:50:17 +0000 (08:50 +0800)]
xfs: xfs_dir3_sfe_put_ino can be static

TO: Dave Chinner <david@fromorbit.com>
CC: Ben Myers <bpm@sgi.com>
CC: linux-kernel@vger.kernel.org
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: introduce object readahead to log recovery
Zhi Yong Wu [Wed, 14 Aug 2013 07:16:03 +0000 (15:16 +0800)]
xfs: introduce object readahead to log recovery

  It can take a long time to run log recovery operation because it is
single threaded and is bound by read latency. We can find that it took
most of the time to wait for the read IO to occur, so if one object
readahead is introduced to log recovery, it will obviously reduce the
log recovery time.

Log recovery time stat:

          w/o this patch        w/ this patch

real:        0m15.023s             0m7.802s
user:        0m0.001s              0m0.001s
sys:         0m0.246s              0m0.107s

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Simplify xfs_ail_min() with list_first_entry_or_null()
Jie Liu [Thu, 15 Aug 2013 05:08:35 +0000 (13:08 +0800)]
xfs: Simplify xfs_ail_min() with list_first_entry_or_null()

At xfs_ail_min(), we do check if the AIL list is empty or not before
returning the first item in it with list_empty() and list_first_entry().

This can be simplified a bit with a new list operation routine that is
the list_first_entry_or_null() which has been introduced by:

commit 6d7581e62f8be462440d7b22c6361f7c9fa4902b
    list: introduce list_first_entry_or_null

v2: make xfs_ail_min() as a static inline function and move it to
    xfs_trans_priv.h as per Dave Chinner's comments.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Register hotcpu notifier after initialization
Richard Weinberger [Mon, 19 Aug 2013 20:56:44 +0000 (22:56 +0200)]
xfs: Register hotcpu notifier after initialization

Currently the code initializizes mp->m_icsb_mutex and other things
_after_ register_hotcpu_notifier().
As the notifier takes mp->m_icsb_mutex it can happen
that it takes the lock before it's initialization.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: add xfs sb v4 support for dirent filetype field
Mark Tinguely [Mon, 19 Aug 2013 20:19:36 +0000 (15:19 -0500)]
xfs: add xfs sb v4 support for dirent filetype field

Add XFS superblock v4 support for the file type field in the
directory entry feature.

This support adds a feature bit for version 4 superblocks and
leaves the original superblock 5 incompatibility bit.

Signed-off-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Geoffrey Wehrman <gwehrman@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Add write support for dirent filetype field
Dave Chinner [Mon, 12 Aug 2013 10:50:10 +0000 (20:50 +1000)]
xfs: Add write support for dirent filetype field

Add support to propagate and add filetype values into the on-disk
directs. This involves passing the filetype into the xfs_da_args
structure along with the name and namelength for direct operations,
and encoding it into the dirent at the same time we write the inode
number into the dirent.

With write support, add the feature flag to the
XFS_SB_FEAT_INCOMPAT_ALL mask so we can now mount filesystems with
this feature set.

Performance of directory recursion is now much improved. Parallel
walk of ~50 million directory entries across hundreds of directories
improves significantly. Unpatched, no CRCs:

Walking via ls -R

real    3m19.886s
user    6m36.960s
sys     28m19.087s

THis is doing roughly 500 getdents() calls per second, and 250,000
inode lookups per second to determine the inode type at roughly
17,000 read IOPS. CPU usage is 90% kernel space.

With dtype support patched in and the fileset recreated with CRCs
enabled:

Walking via ls -R

real    0m31.316s
user    6m32.975s
sys     0m21.111s

This is doing roughly 3500 getdents() calls per second at 16,000
IOPS. There are no inode lookups at all. CPU usages is almost 100%
userspace.

This is a big win for recursive directory walks that only need to
find file names and file types.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Add read-only support for dirent filetype field
Dave Chinner [Mon, 12 Aug 2013 10:50:09 +0000 (20:50 +1000)]
xfs: Add read-only support for dirent filetype field

Add support for the file type field in directory entries so that
readdir can return the type of the inode the dirent points to to
userspace without first having to read the inode off disk.

The encoding of the type field is a single byte that is added to the
end of the directory entry name length. For all intents and
purposes, it appends a "hidden" byte to the name field which
contains the type information. As the directory entry is already of
dynamic size, helpers are already required to access and decode the
direct entry structures.

Hence the relevent extraction and iteration helpers are updated to
understand the hidden byte.  Helpers for reading and writing the
filetype field from the directory entries are also added. Only the
read helpers are used by this patch.  It also adds all the code
necessary to read the type information out of the dirents on disk.

Further we add the superblock feature bit and helpers to indicate
that we understand the on-disk format change. This is not a
compatible change - existing kernels cannot read the new format
successfully - so an incompatible feature flag is added. We don't
yet allow filesystems to mount with this flag yet - that will be
added once write support is added.

Finally, the code to take the type from the VFS, convert it to an
XFS on-disk type and put it into the xfs_name structures passed
around is added, but the directory code does not use this field yet.
That will be in the next patch.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agopowerpc/spufs: convert userns uid/gid mount options to kuid/kgid
Dwight Engen [Wed, 21 Aug 2013 18:33:51 +0000 (14:33 -0400)]
powerpc/spufs: convert userns uid/gid mount options to kuid/kgid

Acked-by: Jeremy Kerr <jk@ozlabs.org>
Tested-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Add support for the Q_XGETQSTATV
Chandra Seetharaman [Tue, 6 Aug 2013 22:27:08 +0000 (17:27 -0500)]
xfs: Add support for the Q_XGETQSTATV

For XFS, add support for Q_XGETQSTATV quotactl command.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoquota: Add a new quotactl command Q_XGETQSTATV
Chandra Seetharaman [Tue, 6 Aug 2013 22:27:07 +0000 (17:27 -0500)]
quota: Add a new quotactl command Q_XGETQSTATV

XFS now supports three types of quotas (user, group and project).

Current version of Q_XGETSTAT has support for only two types of quotas.
In order to support three types of quotas, the interface, specifically
struct fs_quota_stat, need to be expanded. Current version of fs_quota_stat
does not allow expansion without breaking backward compatibility.

So, a quotactl command and new fs_quota_stat structure need to be added.

This patch adds a new command Q_XGETQSTATV to quotactl() which takes
a new data structure fs_quota_statv. This new data structure provides
support for future expansion and backward compatibility.

Callers of the new quotactl command have to set the version of the data
structure being passed, and kernel will fill as much data as requested.
If the kernel does not support the user-space provided version, EINVAL
will be returned. User-space can reduce the version number and call the same
quotactl again.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
[v2: Applied rjohnston's suggestions as per Chandra's request. -bpm]

11 years agoxfs: fix the comment of xfs_mountfs()
Zhi Yong Wu [Mon, 12 Aug 2013 03:15:03 +0000 (03:15 +0000)]
xfs: fix the comment of xfs_mountfs()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_sb_quiet_read_verify()
Zhi Yong Wu [Mon, 12 Aug 2013 03:15:02 +0000 (03:15 +0000)]
xfs: fix the comment of xfs_sb_quiet_read_verify()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xlog_recover_do_dquot_buffer()
Zhi Yong Wu [Mon, 12 Aug 2013 03:15:01 +0000 (03:15 +0000)]
xfs: fix the comment of xlog_recover_do_dquot_buffer()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_log_unmount_write()
Zhi Yong Wu [Mon, 12 Aug 2013 03:15:00 +0000 (03:15 +0000)]
xfs: fix the comment of xfs_log_unmount_write()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_ifree_cluster()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:59 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_ifree_cluster()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_ialloc_ag_select()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:58 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_ialloc_ag_select()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_extent_busy_update_extent()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:57 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_extent_busy_update_extent()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_setsize_buftarg_early()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:56 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_setsize_buftarg_early()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_bmap_punch_delalloc_range()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:55 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_bmap_punch_delalloc_range()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_bmap_last_before()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:54 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_bmap_last_before()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_bmap_validate_ret()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:53 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_bmap_validate_ret()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_bmap_count_tree()
Zhi Yong Wu [Mon, 12 Aug 2013 03:14:52 +0000 (03:14 +0000)]
xfs: fix the comment of xfs_bmap_count_tree()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: rename bio_add_buffer() to xfs_bio_add_buffer()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:09 +0000 (10:11 +0000)]
xfs: rename bio_add_buffer() to xfs_bio_add_buffer()

Follow up with xfs naming style.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xlog_find_head()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:08 +0000 (10:11 +0000)]
xfs: fix the comment of xlog_find_head()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xlog_recover_buffer_pass2()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:07 +0000 (10:11 +0000)]
xfs: fix the comment of xlog_recover_buffer_pass2()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: remove two unused macro definitions in xfs_linux.h
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:06 +0000 (10:11 +0000)]
xfs: remove two unused macro definitions in xfs_linux.h

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_btree_get_iroot()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:05 +0000 (10:11 +0000)]
xfs: fix the comment of xfs_btree_get_iroot()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_iroot_realloc()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:04 +0000 (10:11 +0000)]
xfs: fix the comment of xfs_iroot_realloc()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: remove one blank line in xfs_btree_make_block_unfull()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:03 +0000 (10:11 +0000)]
xfs: remove one blank line in xfs_btree_make_block_unfull()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xlog_write_setup_copy()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:02 +0000 (10:11 +0000)]
xfs: fix the comment of xlog_write_setup_copy()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_mod_incore_sb_unlocked()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:01 +0000 (10:11 +0000)]
xfs: fix the comment of xfs_mod_incore_sb_unlocked()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_btree_lookup()
Zhi Yong Wu [Wed, 7 Aug 2013 10:11:00 +0000 (10:11 +0000)]
xfs: fix the comment of xfs_btree_lookup()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_buf_free()
Zhi Yong Wu [Wed, 7 Aug 2013 10:10:59 +0000 (10:10 +0000)]
xfs: fix the comment of xfs_buf_free()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix the comment of xfs_check_sizes()
Zhi Yong Wu [Wed, 7 Aug 2013 10:10:58 +0000 (10:10 +0000)]
xfs: fix the comment of xfs_check_sizes()

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: use reference counts to free clean buffer items
Dave Chinner [Mon, 12 Aug 2013 10:50:11 +0000 (20:50 +1000)]
xfs: use reference counts to free clean buffer items

When a transaction is cancelled and the buffer log item is clean in
the transaction, the buffer log item is unconditionally freed. If
the log item is in the AIL, however, this leads to a use after free
condition as the item still has other users.

In this case, xfs_buf_item_relse() should only be called on clean
buffer items if the reference count has dropped to zero. This
ensures only the last user frees the item.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoenable building user namespace with xfs
Dwight Engen [Thu, 15 Aug 2013 18:08:04 +0000 (14:08 -0400)]
enable building user namespace with xfs

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: add capability check to free eofblocks ioctl
Dwight Engen [Thu, 15 Aug 2013 18:08:03 +0000 (14:08 -0400)]
xfs: add capability check to free eofblocks ioctl

Check for CAP_SYS_ADMIN since the caller can truncate preallocated
blocks from files they do not own nor have write access to. A more
fine grained access check was considered: require the caller to
specify their own uid/gid and to use inode_permission to check for
write, but this would not catch the case of an inode not reachable
via path traversal from the callers mount namespace.

Add check for read-only filesystem to free eofblocks ioctl.

Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: create internal eofblocks structure with kuid_t types
Dwight Engen [Thu, 15 Aug 2013 18:08:02 +0000 (14:08 -0400)]
xfs: create internal eofblocks structure with kuid_t types

Have eofblocks ioctl convert uid_t to kuid_t into internal structure.
Update internal filter matching to compare ids with kuid_t types.

Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: convert kuid_t to/from uid_t for internal structures
Dwight Engen [Thu, 15 Aug 2013 18:08:01 +0000 (14:08 -0400)]
xfs: convert kuid_t to/from uid_t for internal structures

Use uint32 from init_user_ns for xfs internal uid/gid
representation in xfs_icdinode, xfs_dqid_t.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: ioctl check for capabilities in the current user namespace
Dwight Engen [Thu, 15 Aug 2013 18:08:00 +0000 (14:08 -0400)]
xfs: ioctl check for capabilities in the current user namespace

Use inode_capable() to check if SUID|SGID bits should be cleared to match
similar check in inode_change_ok().

The check for CAP_LINUX_IMMUTABLE was not modified since all other file
systems also check against init_user_ns rather than current_user_ns.

Only allow changing of projid from init_user_ns.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: convert kuid_t to/from uid_t in ACLs
Dwight Engen [Thu, 15 Aug 2013 18:07:59 +0000 (14:07 -0400)]
xfs: convert kuid_t to/from uid_t in ACLs

Change permission check for setting ACL to use inode_owner_or_capable()
which will additionally allow a CAP_FOWNER user in a user namespace to
be able to set an ACL on an inode covered by the user namespace mapping.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: create wrappers for converting kuid_t to/from uid_t
Dwight Engen [Thu, 15 Aug 2013 18:07:58 +0000 (14:07 -0400)]
xfs: create wrappers for converting kuid_t to/from uid_t

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split the CIL lock
Dave Chinner [Mon, 12 Aug 2013 10:50:08 +0000 (20:50 +1000)]
xfs: split the CIL lock

The xc_cil_lock is used for two purposes - to protect the CIL
itself, and to protect the push/commit state and lists. These are
two logically separate structures and operations, so can have their
own locks. This means that pushing on the CIL and the commit wait
ordering won't contend for a lock with other transactions that are
completing concurrently. As the CIL insertion is the hottest path
throught eh CIL, this is a big win.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Combine CIL insert and prepare passes
Dave Chinner [Mon, 12 Aug 2013 10:50:07 +0000 (20:50 +1000)]
xfs: Combine CIL insert and prepare passes

Now that all the log item preparation and formatting is done under
the CIL lock, we can get rid of the intermediate log vector chain
used to track items to be inserted into the CIL.

We can already find all the items to be committed from the
transaction handle, so as long as we attach the log vectors to the
item before we insert the items into the CIL, we don't need to
create a log vector chain to pass around.

This means we can move all the item insertion code into and optimise
it into a pair of simple passes across all the items in the
transaction. The first pass does the formatting and accounting, the
second inserts them all into the CIL.

We keep this two pass split so that we can separate the CIL
insertion - which must be done under the CIL spinlock - from the
formatting. We could insert each item into the CIL with a single
pass, but that massively increases the number of times we have to
grab the CIL spinlock. It is much more efficient (and hence
scalable) to do a batch operation and insert all objects in a single
lock grab.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: avoid CIL allocation during insert
Dave Chinner [Mon, 12 Aug 2013 10:50:06 +0000 (20:50 +1000)]
xfs: avoid CIL allocation during insert

Now that we have the size of the log vector that has been allocated,
we can determine if we need to allocate a new log vector for
formatting and insertion. We only need to allocate a new vector if
it won't fit into the existing buffer.

However, we need to hold the CIL context lock while we do this so
that we can't race with a push draining the currently queued log
vectors. It is safe to do this as long as we do GFP_NOFS allocation
to avoid avoid memory allocation recursing into the filesystem.
Hence we can safely overwrite the existing log vector on the CIL if
it is large enough to hold all the dirty regions of the current
item.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Reduce allocations during CIL insertion
Dave Chinner [Mon, 12 Aug 2013 10:50:05 +0000 (20:50 +1000)]
xfs: Reduce allocations during CIL insertion

Now that we have the size of the object before the formatting pass
is called, we can allocation the log vector and it's buffer in a
single allocation rather than two separate allocations.

Store the size of the allocated buffer in the log vector so that
we potentially avoid allocation for future modifications of the
object.

While touching this code, remove the IOP_FORMAT definition.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: return log item size in IOP_SIZE
Dave Chinner [Mon, 12 Aug 2013 10:50:04 +0000 (20:50 +1000)]
xfs: return log item size in IOP_SIZE

To begin optimising the CIL commit process, we need to have IOP_SIZE
return both the number of vectors and the size of the data pointed
to by the vectors. This enables us to calculate the size ofthe
memory allocation needed before the formatting step and reduces the
number of memory allocations per item by one.

While there, kill the IOP_SIZE macro.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs:free bp in xlog_find_tail() error path
Eric Sandeen [Thu, 1 Aug 2013 01:33:47 +0000 (20:33 -0500)]
xfs:free bp in xlog_find_tail() error path

xlog_find_tail() currently leaks a bp on one error path.

There is no error target, so manually free the bp before
returning the error.

Found by Coverity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: free bp in xlog_find_zeroed() error path
Eric Sandeen [Thu, 1 Aug 2013 01:32:30 +0000 (20:32 -0500)]
xfs: free bp in xlog_find_zeroed() error path

xlog_find_zeroed() currently leaks a bp on one error path.

Using the bp_err: target resolves this.

Found by Coverity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: avoid double-free in xfs_attr_node_addname
Eric Sandeen [Thu, 1 Aug 2013 01:18:54 +0000 (20:18 -0500)]
xfs: avoid double-free in xfs_attr_node_addname

xfs_attr_node_addname()'s error handling tests whether it
should free "state" in the out: error handling label:

out:
        if (state)
                xfs_da_state_free(state);

but an earlier free doesn't set state to NULL afterwards; this
could lead to a double free.  Fix it by setting state to NULL
after it's freed.

This was found by Coverity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: call roundup_64() to calculate the min_logblks
Jie Liu [Tue, 13 Aug 2013 05:32:00 +0000 (13:32 +0800)]
xfs: call roundup_64() to calculate the min_logblks

Replace roundup() with roundup_64() as we calculate min_logblks
with 64-bit divisions.  Hence, call roundup() will cause the
following error while compiling a 32-bit kernel:

fs/built-in.o: In function `xfs_log_calc_minimum_size':
fs/xfs/xfs_log_rlimit.c:140: undefined reference to `__udivdi3'

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Validate log space at mount time
Jie Liu [Mon, 12 Aug 2013 10:50:03 +0000 (20:50 +1000)]
xfs: Validate log space at mount time

Validate log space during log mount stage, the underlying function
will drop a warning message via syslog in critical level if the log
space is too small or too large.

[ dchinner: For CRC enable filesystems, abort the mounting of the
filesystem as mkfs should never make a log too small for the given
filesystem configuration. ]

[ dchinner: make a note of the fact that the log size limits in
block counts are in units of filesystem blocks, not basic blocks. ]

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Add xfs_log_rlimit.c
Jie Liu [Mon, 12 Aug 2013 10:50:02 +0000 (20:50 +1000)]
xfs: Add xfs_log_rlimit.c

Add source files for xfs_log_rlimit.c The new file is used for log
size calculations and validation shared with userspace.

[dchinner: xfs_log_calc_max_attrsetm_res() does not modify the
tr_attrsetm reservation, just calculates the maximum. ]

[dchinner: rework loop in xfs_log_get_max_trans_res() ]

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Refactor xfs_ticket_alloc() to extract a new helper
Jie Liu [Mon, 12 Aug 2013 10:50:01 +0000 (20:50 +1000)]
xfs: Refactor xfs_ticket_alloc() to extract a new helper

Refactor xlog_ticket_alloc() to extract a new helper, i.e.
xfs_log_calc_unit_res().

This helper would be used to calculate the total log reservation
size by adding extra log operation/transation headers for a new
log ticket.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Get rid of all XFS_XXX_LOG_RES() macro
Jie Liu [Mon, 12 Aug 2013 10:50:00 +0000 (20:50 +1000)]
xfs: Get rid of all XFS_XXX_LOG_RES() macro

Get rid of all XFS_XXX_LOG_RES() macros since they are obsoleted now.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: refactor xfs_trans_reserve() interface
Jie Liu [Mon, 12 Aug 2013 10:49:59 +0000 (20:49 +1000)]
xfs: refactor xfs_trans_reserve() interface

With the new xfs_trans_res structure has been introduced, the log
reservation size, log count as well as log flags are pre-initialized
at mount time.  So it's time to refine xfs_trans_reserve() interface
to be more neat.

Also, introduce a new helper M_RES() to return a pointer to the
mp->m_resv structure to simplify the input.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Make writeid transaction use tr_writeid
Jie Liu [Mon, 12 Aug 2013 10:49:58 +0000 (20:49 +1000)]
xfs: Make writeid transaction use tr_writeid

tr_writeid is defined at mp->m_resv structure, however, it does not
really being used when it should be..

This patch changes it to tr_writeid to fetch the correct log
reservation size.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Introduce tr_fsyncts to m_reservation
Jie Liu [Mon, 12 Aug 2013 10:49:57 +0000 (20:49 +1000)]
xfs: Introduce tr_fsyncts to m_reservation

A preparation step.

For now fsync_ts transaction use the pre-calculated log reservation
size of tr_swrite.  This patch introduce a new item tr_fsyncts to
mp->m_reservations structure so that we can fetch the log
reservation value for it in a same manner to others.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: Introduce a new structure to hold transaction reservation items
Jie Liu [Mon, 12 Aug 2013 10:49:56 +0000 (20:49 +1000)]
xfs: Introduce a new structure to hold transaction reservation items

Introduce a new structure xfs_trans_res to hold transaction
reservation item info per log ticket.

We also need to improve xfs_trans_resv_calc() by initializing the
log count as well as log flags for permanent log reservation.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: make struct xfs_perag kernel only
Dave Chinner [Mon, 12 Aug 2013 10:49:55 +0000 (20:49 +1000)]
xfs: make struct xfs_perag kernel only

The struct xfs_perag has many kernel-only definitions in it,
requiring a __KERNEL__ guard so userspace can use it to. Move it to
xfs_mount.h so that it it kernel-only, and let userspace redefine
it's own version of the structure containing only what it needs.
This gets rid of another __KERNEL__ check in the XFS header files.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: move kernel specific type definitions to xfs.h
Dave Chinner [Mon, 12 Aug 2013 10:49:54 +0000 (20:49 +1000)]
xfs: move kernel specific type definitions to xfs.h

xfs_types.h is shared with userspace, so having kernel specific
types defined in it is problematic. Move all the kernel specific
defines to xfs_linux.h so we can remove the __KERNEL__ guards from
xfs_types.h.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: xfs_filestreams.h doesn't need __KERNEL__
Dave Chinner [Mon, 12 Aug 2013 10:49:53 +0000 (20:49 +1000)]
xfs: xfs_filestreams.h doesn't need __KERNEL__

Because it is only used within the kernel.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: remove __KERNEL__ check from xfs_dir2_leaf.c
Dave Chinner [Mon, 12 Aug 2013 10:49:52 +0000 (20:49 +1000)]
xfs: remove __KERNEL__ check from xfs_dir2_leaf.c

It's actually an ifndef section, which means it is only included in
userspace. however, it's deep within the libxfs code, so it's
unlikely that the condition checked in userspace can actually occur
(search an empty leaf) through the libxfs interfaces. i.e. if it can
happen in usrspace, it can happen in the kernel, so remove it from
userspace too....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: remove __KERNEL__ from debug code
Dave Chinner [Mon, 12 Aug 2013 10:49:51 +0000 (20:49 +1000)]
xfs: remove __KERNEL__ from debug code

There is no reason the remaining kernel-only debug code needs to
remain kernel-only. Kill the __KERNEL__ part of the defines, and let
userspace handle the debug code appropriately.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: kill __KERNEL__ check for debug code in allocation code
Dave Chinner [Mon, 12 Aug 2013 10:49:50 +0000 (20:49 +1000)]
xfs: kill __KERNEL__ check for debug code in allocation code

Userspace running debug builds is relatively rare, so there's need
to special case the allocation algorithm code coverage debug switch.
As it is, userspace defines random numbers to 0, so  invert the
logic of the switch so it is effectively a no-op in userspace.
This kills another couple of __KERNEL__ users.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: don't special case shared superblock mounts
Dave Chinner [Mon, 12 Aug 2013 10:49:49 +0000 (20:49 +1000)]
xfs: don't special case shared superblock mounts

Neither kernel or userspace support shared read-only mounts, so
don't bother special casing the support check to be different
between kernel and userspace. The same check can be used as neither
like it...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: consolidate extent swap code
Dave Chinner [Mon, 12 Aug 2013 10:49:48 +0000 (20:49 +1000)]
xfs: consolidate extent swap code

So we don't need xfs_dfrag.h in userspace anymore, move the extent
swap ioctl structure definition to xfs_fs.h where most of the other
ioctl structure definitions are.

Now that we don't need separate files for extent swapping, separate
the basic file descriptor checking code to xfs_ioctl.c, and the code
that does the extent swap operation to xfs_bmap_util.c.  This
cleanly separates the user interface code from the physical
mechanism used to do the extent swap.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: consolidate xfs_utils.c
Dave Chinner [Mon, 12 Aug 2013 10:49:47 +0000 (20:49 +1000)]
xfs: consolidate xfs_utils.c

There are a few small helper functions in xfs_util, all related to
xfs_inode modifications. Move them all to xfs_inode.c so all
xfs_inode operations are consiolidated in the one place.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: consolidate xfs_rename.c
Dave Chinner [Mon, 12 Aug 2013 10:49:46 +0000 (20:49 +1000)]
xfs: consolidate xfs_rename.c

Move the rename code to xfs_inode.c to continue consolidating
all the kernel xfs_inode operations in the one place.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: kill xfs_vnodeops.[ch]
Dave Chinner [Mon, 12 Aug 2013 10:49:45 +0000 (20:49 +1000)]
xfs: kill xfs_vnodeops.[ch]

Now we have xfs_inode.c for holding kernel-only XFS inode
operations, move all the inode operations from xfs_vnodeops.c to
this new file as it holds another set of kernel-only inode
operations. The name of this file traces back to the days of Irix
and it's vnodes which we don't have anymore.

Essentially this move consolidates the inode locking functions
and a bunch of XFS inode operations into the one file. Eventually
the high level functions will be merged into the VFS interface
functions in xfs_iops.c.

This leaves only internal preallocation, EOF block manipulation and
hole punching functions in vnodeops.c. Move these to xfs_bmap_util.c
where we are already consolidating various in-kernel physical extent
manipulation and querying functions.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: fix issues that cause userspace warnings
Dave Chinner [Mon, 12 Aug 2013 10:49:44 +0000 (20:49 +1000)]
xfs: fix issues that cause userspace warnings

Some of the code shared with userspace causes compilation warnings
from things turned off in the kernel code, such as differences in
variable signedness. Fix those issues.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: minor cleanups
Dave Chinner [Mon, 12 Aug 2013 10:49:43 +0000 (20:49 +1000)]
xfs: minor cleanups

These come from syncing the shared userspace and kernel code. Small
whitespace and trivial cleanups.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: create xfs_bmap_util.[ch]
Dave Chinner [Mon, 12 Aug 2013 10:49:42 +0000 (20:49 +1000)]
xfs: create xfs_bmap_util.[ch]

There is a bunch of code in xfs_bmap.c that is kernel specific and
not shared with userspace. To minimise the difference between the
kernel and userspace code, shift this unshared code to
xfs_bmap_util.c, and the declarations to xfs_bmap_util.h.

The biggest issue here is xfs_bmap_finish() - userspace has it's own
definition of this function, and so we need to move it out of
xfs_bmap.[ch]. This means several other files need to include
xfs_bmap_util.h as well.

It also introduces and interesting dance for the stack switching
code in xfs_bmapi_allocate(). The stack switching/workqueue code is
actually moved to xfs_bmap_util.c, so that userspace can simply use
a #define in a header file to connect the dots without needing to
know about the stack switch code at all.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: introduce xfs_sb.c for sharing with libxfs
Dave Chinner [Mon, 12 Aug 2013 10:49:41 +0000 (20:49 +1000)]
xfs: introduce xfs_sb.c for sharing with libxfs

xfs_mount.c is shared with userspace, but the only functions that
are shared are to do with physical superblock manipulations. This
means that less than 25% of the xfs_mount.c code is actually shared
with userspace. Move all the superblock functions to xfs_sb.c and
share that instead with libxfs.

Note that this will leave all the in-core transaction related
superblock counter modifications in xfs_mount.c as none of that is
shared with userspace. With a few more small changes, xfs_mount.h
won't need to be shared with userspace anymore, either.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out the remote symlink handling
Dave Chinner [Mon, 12 Aug 2013 10:49:40 +0000 (20:49 +1000)]
xfs: split out the remote symlink handling

The remote symlink format definition and manipulation needs to be
shared with userspace, but the in-kernel interfaces do not. Split
the remote symlink format handling out into xfs_symlink_remote.[ch]
fo it can easily be shared with userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out attribute fork truncation code into separate file
Dave Chinner [Mon, 12 Aug 2013 10:49:39 +0000 (20:49 +1000)]
xfs: split out attribute fork truncation code into separate file

The attribute inactivation code is not used by userspace, so like
the attribute listing, split it out into a separate file to minimise
the differences between the filesystem shared with libxfs in
userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out attribute listing code into separate file
Dave Chinner [Mon, 12 Aug 2013 10:49:38 +0000 (20:49 +1000)]
xfs: split out attribute listing code into separate file

The attribute listing code is not used by userspace, so like the
directory readdir code, split it out into a separate file to
minimise the differences between the filesystem shared with libxfs
in userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: reshuffle dir2 definitions around for userspace
Dave Chinner [Mon, 12 Aug 2013 10:49:37 +0000 (20:49 +1000)]
xfs: reshuffle dir2 definitions around for userspace

Many of the definitions within xfs_dir2_priv.h are needed in
userspace outside libxfs. Definitions within xfs_dir2_priv.h are
wholly contained within libxfs, so we need to shuffle some of the
definitions around to keep consistency across files shared between
user and kernel space.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: move getdents code into it's own file
Dave Chinner [Mon, 12 Aug 2013 10:49:36 +0000 (20:49 +1000)]
xfs: move getdents code into it's own file

The directory readdir code is not used by userspace, but it is
intermingled with files that are shared with userspace. This makes
it difficult to compare the differences between the userspac eand
kernel files are the userspace files don't have the getdents code in
them. Move all the kernel getdents code to a separate file to bring
the shared content between userspace and kernel files closer
together.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: introduce xfs_inode_buf.c for inode buffer operations
Dave Chinner [Mon, 12 Aug 2013 10:49:35 +0000 (20:49 +1000)]
xfs: introduce xfs_inode_buf.c for inode buffer operations

The only thing remaining in xfs_inode.[ch] are the operations that
read, write or verify physical inodes in their underlying buffers.
Move all this code to xfs_inode_buf.[ch] and so we can stop sharing
xfs_inode.[ch] with userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: move unrelated definitions out of xfs_inode.h
Dave Chinner [Mon, 12 Aug 2013 10:49:34 +0000 (20:49 +1000)]
xfs: move unrelated definitions out of xfs_inode.h

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: move inode fork definitions to a new header file
Dave Chinner [Mon, 12 Aug 2013 10:49:33 +0000 (20:49 +1000)]
xfs: move inode fork definitions to a new header file

The inode fork definitions are a combination of on-disk format
definition and in-memory tracking and manipulation. They are both
shared with userspace, so move them all into their own file so
sharing is easy to do and track.  This removes all inode fork
related information from xfs_inode.h.

Do the same for the all the C code that currently resides in
xfs_inode.c for the same reason.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out transaction reservation code
Dave Chinner [Mon, 12 Aug 2013 10:49:32 +0000 (20:49 +1000)]
xfs: split out transaction reservation code

The transaction reservation size calculations is used by both kernel
and userspace, but most of the transaction code in xfs_trans.c is
kernel specific. Split all the transaction reservation code out into
it's own files to make sharing with userspace simpler. This just
leaves kernel-only definitions in xfs_trans.h, so it doesn't need to
be shared with userspace anymore, either.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: sync minor header differences needed by userspace.
Dave Chinner [Mon, 12 Aug 2013 10:49:31 +0000 (20:49 +1000)]
xfs: sync minor header differences needed by userspace.

Little things like exported functions, __KERNEL__ protections, and
so on that ensure user and kernel shared headers are identical.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: introduce xfs_quota_defs.h
Dave Chinner [Mon, 12 Aug 2013 10:49:30 +0000 (20:49 +1000)]
xfs: introduce xfs_quota_defs.h

There are a lot of quota flag definitions that are shared by user
and kernel space. Move them all to xfs_quota_defs.h so we can
unshare xfs_quota.h and remove the __KERNEL__ regions from it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: introduce xfs_rtalloc_defs.h
Dave Chinner [Mon, 12 Aug 2013 10:49:29 +0000 (20:49 +1000)]
xfs: introduce xfs_rtalloc_defs.h

There are quite a few realtime device definitions shared with
userspace. Move them from xfs_rtalloc.h to xfs_rt_alloc_defs.h
so we don't need to share xfs_rtalloc.h with userspace anymore.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out on-disk transaction definitions
Dave Chinner [Mon, 12 Aug 2013 10:49:28 +0000 (20:49 +1000)]
xfs: split out on-disk transaction definitions

There's a bunch of definitions in xfs_trans.h that define on-disk
formats - transaction headers that get written into the log, log
item type definitions, etc. Split out everything into a separate
file so that all which remains in xfs_trans.h are kernel only
definitions.

Also, remove the duplicate magic number definitions for
XFS_TRANS_MAGIC...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: separate icreate log format definitions from xfs_icreate_item.h
Dave Chinner [Mon, 12 Aug 2013 10:49:27 +0000 (20:49 +1000)]
xfs: separate icreate log format definitions from xfs_icreate_item.h

The on disk log format definitions for the icreate log item are
intertwined with the kernel-only in-memory log item definitions.
Separate the log format definitions out into their own header file
so they can easily be shared with userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: separate dquot on disk format definitions out of xfs_quota.h
Dave Chinner [Mon, 12 Aug 2013 10:49:26 +0000 (20:49 +1000)]
xfs: separate dquot on disk format definitions out of xfs_quota.h

The on disk format definitions of the on-disk dquot, log formats and
quota off log formats are all intertwined with other definitions for
quotas. Separate them out into their own header file so they can
easily be shared with userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out EFI/EFD log item format definition
Dave Chinner [Mon, 12 Aug 2013 10:49:25 +0000 (20:49 +1000)]
xfs: split out EFI/EFD log item format definition

The EFI/EFD item format definitions are shared with userspace. Split
the out of header files that contain kernel only defintions to make
it simple to shared them.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out buf log item format definitions
Dave Chinner [Mon, 12 Aug 2013 10:49:24 +0000 (20:49 +1000)]
xfs: split out buf log item format definitions

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: split out inode log item format definition
Dave Chinner [Mon, 12 Aug 2013 10:49:23 +0000 (20:49 +1000)]
xfs: split out inode log item format definition

The log item format definitions are shared with userspace. Split
them out of header files that contain kernel only defintions to make
it simple to shared them.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: separate out log format definitions
Dave Chinner [Mon, 12 Aug 2013 10:49:22 +0000 (20:49 +1000)]
xfs: separate out log format definitions

The on-disk format definitions for the log are spread randoms
through a couple of header files. Consolidate it all in a single
file that can be shared easily with userspace. This means that
xfs_log.h and xfs_log_priv.h no longer need to be shared with
userspace.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
11 years agoxfs: WQ_NON_REENTRANT is meaningless and going away
Tejun Heo [Tue, 30 Jul 2013 12:40:26 +0000 (08:40 -0400)]
xfs: WQ_NON_REENTRANT is meaningless and going away

dbf2576e37 ("workqueue: make all workqueues non-reentrant") made
WQ_NON_REENTRANT no-op and the flag is going away.  Remove its usages.

This patch doesn't introduce any behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ben Myers <bpm@sgi.com>
Cc: Alex Elder <elder@kernel.org>
Cc: xfs@oss.sgi.com
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>