aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 14:53:39 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 14:53:39 -0500
commit958b7f37ee0fb2846c8d44310a68ae9605614ff9 (patch)
treeb1644d08d2e2a8d408c66c6d21a89fd815e16015 /fs/xfs
parentd68798374bcf5cd4a19105b86d96121651b3c8cb (diff)
parente7ff6aed8761b2c86cd9ab7083e512de2b8cfa48 (diff)
Merge git://oss.sgi.com:8090/xfs/xfs-2.6
* git://oss.sgi.com:8090/xfs/xfs-2.6: (33 commits) [XFS] Don't use kmap in xfs_iozero. [XFS] Remove a bunch of unused functions from XFS. [XFS] Remove unused arguments from the XFS_BTREE_*_ADDR macros. [XFS] Remove unused header files for MAC and CAP checking functionality. [XFS] Make freeze code a little cleaner. [XFS] Remove unused argument to xfs_bmap_finish [XFS] Clean up use of VFS attr flags [XFS] Remove useless memory barrier [XFS] XFS sysctl cleanups [XFS] Fix assertion in xfs_attr_shortform_remove(). [XFS] Fix callers of xfs_iozero() to zero the correct range. [XFS] Ensure a frozen filesystem has a clean log before writing the dummy [XFS] Fix sub-block zeroing for buffered writes into unwritten extents. [XFS] Re-initialize the per-cpu superblock counters after recovery. [XFS] Fix block reservation changes for non-SMP systems. [XFS] Fix block reservation mechanism. [XFS] Make growfs work for amounts greater than 2TB [XFS] Fix inode log item use-after-free on forced shutdown [XFS] Fix attr2 corruption with btree data extents [XFS] Workaround log space issue by increasing XFS_TRANS_PUSH_AIL_RESTARTS ...
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/mrlock.h6
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c15
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c142
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c51
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c48
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c33
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c266
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h4
-rw-r--r--fs/xfs/quota/xfs_dquot.c4
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c8
-rw-r--r--fs/xfs/quota/xfs_qm.c8
-rw-r--r--fs/xfs/quota/xfs_qm_bhv.c4
-rw-r--r--fs/xfs/quota/xfs_qm_stats.c2
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c4
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c2
-rw-r--r--fs/xfs/support/debug.c23
-rw-r--r--fs/xfs/support/debug.h30
-rw-r--r--fs/xfs/support/move.h4
-rw-r--r--fs/xfs/xfs_acl.c1
-rw-r--r--fs/xfs/xfs_alloc_btree.h10
-rw-r--r--fs/xfs/xfs_attr.c49
-rw-r--r--fs/xfs/xfs_attr_leaf.c54
-rw-r--r--fs/xfs/xfs_bit.c2
-rw-r--r--fs/xfs/xfs_bmap.c101
-rw-r--r--fs/xfs/xfs_bmap.h1
-rw-r--r--fs/xfs/xfs_bmap_btree.c86
-rw-r--r--fs/xfs/xfs_bmap_btree.h59
-rw-r--r--fs/xfs/xfs_btree.h6
-rw-r--r--fs/xfs/xfs_buf_item.c2
-rw-r--r--fs/xfs/xfs_buf_item.h18
-rw-r--r--fs/xfs/xfs_cap.h70
-rw-r--r--fs/xfs/xfs_da_btree.c18
-rw-r--r--fs/xfs/xfs_da_btree.h1
-rw-r--r--fs/xfs/xfs_dfrag.c1
-rw-r--r--fs/xfs/xfs_error.c26
-rw-r--r--fs/xfs/xfs_error.h3
-rw-r--r--fs/xfs/xfs_extfree_item.c4
-rw-r--r--fs/xfs/xfs_fsops.c60
-rw-r--r--fs/xfs/xfs_ialloc.c2
-rw-r--r--fs/xfs/xfs_ialloc_btree.h10
-rw-r--r--fs/xfs/xfs_inode.c30
-rw-r--r--fs/xfs/xfs_inode_item.c2
-rw-r--r--fs/xfs/xfs_iomap.c10
-rw-r--r--fs/xfs/xfs_log_recover.c61
-rw-r--r--fs/xfs/xfs_mac.h106
-rw-r--r--fs/xfs/xfs_mount.c288
-rw-r--r--fs/xfs/xfs_mount.h39
-rw-r--r--fs/xfs/xfs_rename.c2
-rw-r--r--fs/xfs/xfs_rtalloc.c110
-rw-r--r--fs/xfs/xfs_rtalloc.h18
-rw-r--r--fs/xfs/xfs_rw.c1
-rw-r--r--fs/xfs/xfs_trans.c32
-rw-r--r--fs/xfs/xfs_trans.h46
-rw-r--r--fs/xfs/xfs_trans_ail.c2
-rw-r--r--fs/xfs/xfs_vfsops.c45
-rw-r--r--fs/xfs/xfs_vnodeops.c22
63 files changed, 885 insertions, 1189 deletions
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/linux-2.6/mrlock.h
index 32e1ce0f04c9..af168a1a98c1 100644
--- a/fs/xfs/linux-2.6/mrlock.h
+++ b/fs/xfs/linux-2.6/mrlock.h
@@ -31,15 +31,13 @@ typedef struct {
31 do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0) 31 do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
32#define mrlock_init(mrp, t,n,s) mrinit(mrp, n) 32#define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
33#define mrfree(mrp) do { } while (0) 33#define mrfree(mrp) do { } while (0)
34#define mraccess(mrp) mraccessf(mrp, 0)
35#define mrupdate(mrp) mrupdatef(mrp, 0)
36 34
37static inline void mraccessf(mrlock_t *mrp, int flags) 35static inline void mraccess(mrlock_t *mrp)
38{ 36{
39 down_read(&mrp->mr_lock); 37 down_read(&mrp->mr_lock);
40} 38}
41 39
42static inline void mrupdatef(mrlock_t *mrp, int flags) 40static inline void mrupdate(mrlock_t *mrp)
43{ 41{
44 down_write(&mrp->mr_lock); 42 down_write(&mrp->mr_lock);
45 mrp->mr_writer = 1; 43 mrp->mr_writer = 1;
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 7b54461695e2..f3cc4ab20ba0 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -249,7 +249,7 @@ xfs_map_blocks(
249 return -error; 249 return -error;
250} 250}
251 251
252STATIC inline int 252STATIC_INLINE int
253xfs_iomap_valid( 253xfs_iomap_valid(
254 xfs_iomap_t *iomapp, 254 xfs_iomap_t *iomapp,
255 loff_t offset) 255 loff_t offset)
@@ -1283,13 +1283,18 @@ __xfs_get_blocks(
1283 bh_result->b_bdev = iomap.iomap_target->bt_bdev; 1283 bh_result->b_bdev = iomap.iomap_target->bt_bdev;
1284 1284
1285 /* 1285 /*
1286 * If we previously allocated a block out beyond eof and we are 1286 * If we previously allocated a block out beyond eof and we are now
1287 * now coming back to use it then we will need to flag it as new 1287 * coming back to use it then we will need to flag it as new even if it
1288 * even if it has a disk address. 1288 * has a disk address.
1289 *
1290 * With sub-block writes into unwritten extents we also need to mark
1291 * the buffer as new so that the unwritten parts of the buffer gets
1292 * correctly zeroed.
1289 */ 1293 */
1290 if (create && 1294 if (create &&
1291 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || 1295 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
1292 (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) 1296 (offset >= i_size_read(inode)) ||
1297 (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN))))
1293 set_buffer_new(bh_result); 1298 set_buffer_new(bh_result);
1294 1299
1295 if (iomap.iomap_flags & IOMAP_DELAY) { 1300 if (iomap.iomap_flags & IOMAP_DELAY) {
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 4fb01ffdfd1a..e2bea6a661f0 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -34,13 +34,13 @@
34#include <linux/backing-dev.h> 34#include <linux/backing-dev.h>
35#include <linux/freezer.h> 35#include <linux/freezer.h>
36 36
37STATIC kmem_zone_t *xfs_buf_zone; 37static kmem_zone_t *xfs_buf_zone;
38STATIC kmem_shaker_t xfs_buf_shake; 38static kmem_shaker_t xfs_buf_shake;
39STATIC int xfsbufd(void *); 39STATIC int xfsbufd(void *);
40STATIC int xfsbufd_wakeup(int, gfp_t); 40STATIC int xfsbufd_wakeup(int, gfp_t);
41STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int); 41STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int);
42 42
43STATIC struct workqueue_struct *xfslogd_workqueue; 43static struct workqueue_struct *xfslogd_workqueue;
44struct workqueue_struct *xfsdatad_workqueue; 44struct workqueue_struct *xfsdatad_workqueue;
45 45
46#ifdef XFS_BUF_TRACE 46#ifdef XFS_BUF_TRACE
@@ -139,7 +139,7 @@ page_region_mask(
139 return mask; 139 return mask;
140} 140}
141 141
142STATIC inline void 142STATIC_INLINE void
143set_page_region( 143set_page_region(
144 struct page *page, 144 struct page *page,
145 size_t offset, 145 size_t offset,
@@ -151,7 +151,7 @@ set_page_region(
151 SetPageUptodate(page); 151 SetPageUptodate(page);
152} 152}
153 153
154STATIC inline int 154STATIC_INLINE int
155test_page_region( 155test_page_region(
156 struct page *page, 156 struct page *page,
157 size_t offset, 157 size_t offset,
@@ -171,9 +171,9 @@ typedef struct a_list {
171 struct a_list *next; 171 struct a_list *next;
172} a_list_t; 172} a_list_t;
173 173
174STATIC a_list_t *as_free_head; 174static a_list_t *as_free_head;
175STATIC int as_list_len; 175static int as_list_len;
176STATIC DEFINE_SPINLOCK(as_lock); 176static DEFINE_SPINLOCK(as_lock);
177 177
178/* 178/*
179 * Try to batch vunmaps because they are costly. 179 * Try to batch vunmaps because they are costly.
@@ -1085,7 +1085,7 @@ xfs_buf_iostart(
1085 return status; 1085 return status;
1086} 1086}
1087 1087
1088STATIC __inline__ int 1088STATIC_INLINE int
1089_xfs_buf_iolocked( 1089_xfs_buf_iolocked(
1090 xfs_buf_t *bp) 1090 xfs_buf_t *bp)
1091{ 1091{
@@ -1095,7 +1095,7 @@ _xfs_buf_iolocked(
1095 return 0; 1095 return 0;
1096} 1096}
1097 1097
1098STATIC __inline__ void 1098STATIC_INLINE void
1099_xfs_buf_ioend( 1099_xfs_buf_ioend(
1100 xfs_buf_t *bp, 1100 xfs_buf_t *bp,
1101 int schedule) 1101 int schedule)
@@ -1426,8 +1426,8 @@ xfs_free_bufhash(
1426/* 1426/*
1427 * buftarg list for delwrite queue processing 1427 * buftarg list for delwrite queue processing
1428 */ 1428 */
1429STATIC LIST_HEAD(xfs_buftarg_list); 1429LIST_HEAD(xfs_buftarg_list);
1430STATIC DEFINE_SPINLOCK(xfs_buftarg_lock); 1430static DEFINE_SPINLOCK(xfs_buftarg_lock);
1431 1431
1432STATIC void 1432STATIC void
1433xfs_register_buftarg( 1433xfs_register_buftarg(
@@ -1679,21 +1679,60 @@ xfsbufd_wakeup(
1679 return 0; 1679 return 0;
1680} 1680}
1681 1681
1682/*
1683 * Move as many buffers as specified to the supplied list
1684 * idicating if we skipped any buffers to prevent deadlocks.
1685 */
1686STATIC int
1687xfs_buf_delwri_split(
1688 xfs_buftarg_t *target,
1689 struct list_head *list,
1690 unsigned long age)
1691{
1692 xfs_buf_t *bp, *n;
1693 struct list_head *dwq = &target->bt_delwrite_queue;
1694 spinlock_t *dwlk = &target->bt_delwrite_lock;
1695 int skipped = 0;
1696 int force;
1697
1698 force = test_and_clear_bit(XBT_FORCE_FLUSH, &target->bt_flags);
1699 INIT_LIST_HEAD(list);
1700 spin_lock(dwlk);
1701 list_for_each_entry_safe(bp, n, dwq, b_list) {
1702 XB_TRACE(bp, "walkq1", (long)xfs_buf_ispin(bp));
1703 ASSERT(bp->b_flags & XBF_DELWRI);
1704
1705 if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) {
1706 if (!force &&
1707 time_before(jiffies, bp->b_queuetime + age)) {
1708 xfs_buf_unlock(bp);
1709 break;
1710 }
1711
1712 bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|
1713 _XBF_RUN_QUEUES);
1714 bp->b_flags |= XBF_WRITE;
1715 list_move_tail(&bp->b_list, list);
1716 } else
1717 skipped++;
1718 }
1719 spin_unlock(dwlk);
1720
1721 return skipped;
1722
1723}
1724
1682STATIC int 1725STATIC int
1683xfsbufd( 1726xfsbufd(
1684 void *data) 1727 void *data)
1685{ 1728{
1686 struct list_head tmp; 1729 struct list_head tmp;
1687 unsigned long age; 1730 xfs_buftarg_t *target = (xfs_buftarg_t *)data;
1688 xfs_buftarg_t *target = (xfs_buftarg_t *)data; 1731 int count;
1689 xfs_buf_t *bp, *n; 1732 xfs_buf_t *bp;
1690 struct list_head *dwq = &target->bt_delwrite_queue;
1691 spinlock_t *dwlk = &target->bt_delwrite_lock;
1692 int count;
1693 1733
1694 current->flags |= PF_MEMALLOC; 1734 current->flags |= PF_MEMALLOC;
1695 1735
1696 INIT_LIST_HEAD(&tmp);
1697 do { 1736 do {
1698 if (unlikely(freezing(current))) { 1737 if (unlikely(freezing(current))) {
1699 set_bit(XBT_FORCE_SLEEP, &target->bt_flags); 1738 set_bit(XBT_FORCE_SLEEP, &target->bt_flags);
@@ -1705,37 +1744,17 @@ xfsbufd(
1705 schedule_timeout_interruptible( 1744 schedule_timeout_interruptible(
1706 xfs_buf_timer_centisecs * msecs_to_jiffies(10)); 1745 xfs_buf_timer_centisecs * msecs_to_jiffies(10));
1707 1746
1708 count = 0; 1747 xfs_buf_delwri_split(target, &tmp,
1709 age = xfs_buf_age_centisecs * msecs_to_jiffies(10); 1748 xfs_buf_age_centisecs * msecs_to_jiffies(10));
1710 spin_lock(dwlk);
1711 list_for_each_entry_safe(bp, n, dwq, b_list) {
1712 XB_TRACE(bp, "walkq1", (long)xfs_buf_ispin(bp));
1713 ASSERT(bp->b_flags & XBF_DELWRI);
1714
1715 if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) {
1716 if (!test_bit(XBT_FORCE_FLUSH,
1717 &target->bt_flags) &&
1718 time_before(jiffies,
1719 bp->b_queuetime + age)) {
1720 xfs_buf_unlock(bp);
1721 break;
1722 }
1723
1724 bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|
1725 _XBF_RUN_QUEUES);
1726 bp->b_flags |= XBF_WRITE;
1727 list_move_tail(&bp->b_list, &tmp);
1728 count++;
1729 }
1730 }
1731 spin_unlock(dwlk);
1732 1749
1750 count = 0;
1733 while (!list_empty(&tmp)) { 1751 while (!list_empty(&tmp)) {
1734 bp = list_entry(tmp.next, xfs_buf_t, b_list); 1752 bp = list_entry(tmp.next, xfs_buf_t, b_list);
1735 ASSERT(target == bp->b_target); 1753 ASSERT(target == bp->b_target);
1736 1754
1737 list_del_init(&bp->b_list); 1755 list_del_init(&bp->b_list);
1738 xfs_buf_iostrategy(bp); 1756 xfs_buf_iostrategy(bp);
1757 count++;
1739 } 1758 }
1740 1759
1741 if (as_list_len > 0) 1760 if (as_list_len > 0)
@@ -1743,7 +1762,6 @@ xfsbufd(
1743 if (count) 1762 if (count)
1744 blk_run_address_space(target->bt_mapping); 1763 blk_run_address_space(target->bt_mapping);
1745 1764
1746 clear_bit(XBT_FORCE_FLUSH, &target->bt_flags);
1747 } while (!kthread_should_stop()); 1765 } while (!kthread_should_stop());
1748 1766
1749 return 0; 1767 return 0;
@@ -1756,40 +1774,24 @@ xfsbufd(
1756 */ 1774 */
1757int 1775int
1758xfs_flush_buftarg( 1776xfs_flush_buftarg(
1759 xfs_buftarg_t *target, 1777 xfs_buftarg_t *target,
1760 int wait) 1778 int wait)
1761{ 1779{
1762 struct list_head tmp; 1780 struct list_head tmp;
1763 xfs_buf_t *bp, *n; 1781 xfs_buf_t *bp, *n;
1764 int pincount = 0; 1782 int pincount = 0;
1765 struct list_head *dwq = &target->bt_delwrite_queue;
1766 spinlock_t *dwlk = &target->bt_delwrite_lock;
1767 1783
1768 xfs_buf_runall_queues(xfsdatad_workqueue); 1784 xfs_buf_runall_queues(xfsdatad_workqueue);
1769 xfs_buf_runall_queues(xfslogd_workqueue); 1785 xfs_buf_runall_queues(xfslogd_workqueue);
1770 1786
1771 INIT_LIST_HEAD(&tmp); 1787 set_bit(XBT_FORCE_FLUSH, &target->bt_flags);
1772 spin_lock(dwlk); 1788 pincount = xfs_buf_delwri_split(target, &tmp, 0);
1773 list_for_each_entry_safe(bp, n, dwq, b_list) {
1774 ASSERT(bp->b_target == target);
1775 ASSERT(bp->b_flags & (XBF_DELWRI | _XBF_DELWRI_Q));
1776 XB_TRACE(bp, "walkq2", (long)xfs_buf_ispin(bp));
1777 if (xfs_buf_ispin(bp)) {
1778 pincount++;
1779 continue;
1780 }
1781
1782 list_move_tail(&bp->b_list, &tmp);
1783 }
1784 spin_unlock(dwlk);
1785 1789
1786 /* 1790 /*
1787 * Dropped the delayed write list lock, now walk the temporary list 1791 * Dropped the delayed write list lock, now walk the temporary list
1788 */ 1792 */
1789 list_for_each_entry_safe(bp, n, &tmp, b_list) { 1793 list_for_each_entry_safe(bp, n, &tmp, b_list) {
1790 xfs_buf_lock(bp); 1794 ASSERT(target == bp->b_target);
1791 bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|_XBF_RUN_QUEUES);
1792 bp->b_flags |= XBF_WRITE;
1793 if (wait) 1795 if (wait)
1794 bp->b_flags &= ~XBF_ASYNC; 1796 bp->b_flags &= ~XBF_ASYNC;
1795 else 1797 else
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 9dd235cb0107..9e8ef8fef39f 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -69,8 +69,8 @@ typedef enum {
69} xfs_buf_flags_t; 69} xfs_buf_flags_t;
70 70
71typedef enum { 71typedef enum {
72 XBT_FORCE_SLEEP = (0 << 1), 72 XBT_FORCE_SLEEP = 0,
73 XBT_FORCE_FLUSH = (1 << 1), 73 XBT_FORCE_FLUSH = 1,
74} xfs_buftarg_flags_t; 74} xfs_buftarg_flags_t;
75 75
76typedef struct xfs_bufhash { 76typedef struct xfs_bufhash {
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index 5fb75d9151f2..e3a5fedac1ba 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -24,7 +24,7 @@
24#include "xfs_mount.h" 24#include "xfs_mount.h"
25#include "xfs_export.h" 25#include "xfs_export.h"
26 26
27STATIC struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, }; 27static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
28 28
29/* 29/*
30 * XFS encodes and decodes the fileid portion of NFS filehandles 30 * XFS encodes and decodes the fileid portion of NFS filehandles
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index d26f5cd2ba70..cb51dc961355 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -46,7 +46,7 @@ static struct vm_operations_struct xfs_file_vm_ops;
46static struct vm_operations_struct xfs_dmapi_file_vm_ops; 46static struct vm_operations_struct xfs_dmapi_file_vm_ops;
47#endif 47#endif
48 48
49STATIC inline ssize_t 49STATIC_INLINE ssize_t
50__xfs_file_read( 50__xfs_file_read(
51 struct kiocb *iocb, 51 struct kiocb *iocb,
52 const struct iovec *iov, 52 const struct iovec *iov,
@@ -84,7 +84,7 @@ xfs_file_aio_read_invis(
84 return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); 84 return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos);
85} 85}
86 86
87STATIC inline ssize_t 87STATIC_INLINE ssize_t
88__xfs_file_write( 88__xfs_file_write(
89 struct kiocb *iocb, 89 struct kiocb *iocb,
90 const struct iovec *iov, 90 const struct iovec *iov,
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index f011c9cd0d62..ff5c41ff8d40 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -41,8 +41,6 @@
41#include "xfs_error.h" 41#include "xfs_error.h"
42#include "xfs_rw.h" 42#include "xfs_rw.h"
43#include "xfs_acl.h" 43#include "xfs_acl.h"
44#include "xfs_cap.h"
45#include "xfs_mac.h"
46#include "xfs_attr.h" 44#include "xfs_attr.h"
47#include "xfs_bmap.h" 45#include "xfs_bmap.h"
48#include "xfs_buf_item.h" 46#include "xfs_buf_item.h"
@@ -355,7 +353,6 @@ STATIC int
355xfs_readlink_by_handle( 353xfs_readlink_by_handle(
356 xfs_mount_t *mp, 354 xfs_mount_t *mp,
357 void __user *arg, 355 void __user *arg,
358 struct file *parfilp,
359 struct inode *parinode) 356 struct inode *parinode)
360{ 357{
361 int error; 358 int error;
@@ -388,7 +385,7 @@ xfs_readlink_by_handle(
388 aiov.iov_len = olen; 385 aiov.iov_len = olen;
389 aiov.iov_base = hreq.ohandle; 386 aiov.iov_base = hreq.ohandle;
390 387
391 auio.uio_iov = &aiov; 388 auio.uio_iov = (struct kvec *)&aiov;
392 auio.uio_iovcnt = 1; 389 auio.uio_iovcnt = 1;
393 auio.uio_offset = 0; 390 auio.uio_offset = 0;
394 auio.uio_segflg = UIO_USERSPACE; 391 auio.uio_segflg = UIO_USERSPACE;
@@ -406,7 +403,6 @@ STATIC int
406xfs_fssetdm_by_handle( 403xfs_fssetdm_by_handle(
407 xfs_mount_t *mp, 404 xfs_mount_t *mp,
408 void __user *arg, 405 void __user *arg,
409 struct file *parfilp,
410 struct inode *parinode) 406 struct inode *parinode)
411{ 407{
412 int error; 408 int error;
@@ -448,7 +444,6 @@ STATIC int
448xfs_attrlist_by_handle( 444xfs_attrlist_by_handle(
449 xfs_mount_t *mp, 445 xfs_mount_t *mp,
450 void __user *arg, 446 void __user *arg,
451 struct file *parfilp,
452 struct inode *parinode) 447 struct inode *parinode)
453{ 448{
454 int error; 449 int error;
@@ -569,7 +564,6 @@ STATIC int
569xfs_attrmulti_by_handle( 564xfs_attrmulti_by_handle(
570 xfs_mount_t *mp, 565 xfs_mount_t *mp,
571 void __user *arg, 566 void __user *arg,
572 struct file *parfilp,
573 struct inode *parinode) 567 struct inode *parinode)
574{ 568{
575 int error; 569 int error;
@@ -689,7 +683,6 @@ xfs_ioc_xattr(
689STATIC int 683STATIC int
690xfs_ioc_getbmap( 684xfs_ioc_getbmap(
691 bhv_desc_t *bdp, 685 bhv_desc_t *bdp,
692 struct file *filp,
693 int flags, 686 int flags,
694 unsigned int cmd, 687 unsigned int cmd,
695 void __user *arg); 688 void __user *arg);
@@ -788,7 +781,7 @@ xfs_ioctl(
788 781
789 case XFS_IOC_GETBMAP: 782 case XFS_IOC_GETBMAP:
790 case XFS_IOC_GETBMAPA: 783 case XFS_IOC_GETBMAPA:
791 return xfs_ioc_getbmap(bdp, filp, ioflags, cmd, arg); 784 return xfs_ioc_getbmap(bdp, ioflags, cmd, arg);
792 785
793 case XFS_IOC_GETBMAPX: 786 case XFS_IOC_GETBMAPX:
794 return xfs_ioc_getbmapx(bdp, arg); 787 return xfs_ioc_getbmapx(bdp, arg);
@@ -802,16 +795,16 @@ xfs_ioctl(
802 return xfs_open_by_handle(mp, arg, filp, inode); 795 return xfs_open_by_handle(mp, arg, filp, inode);
803 796
804 case XFS_IOC_FSSETDM_BY_HANDLE: 797 case XFS_IOC_FSSETDM_BY_HANDLE:
805 return xfs_fssetdm_by_handle(mp, arg, filp, inode); 798 return xfs_fssetdm_by_handle(mp, arg, inode);
806 799
807 case XFS_IOC_READLINK_BY_HANDLE: 800 case XFS_IOC_READLINK_BY_HANDLE:
808 return xfs_readlink_by_handle(mp, arg, filp, inode); 801 return xfs_readlink_by_handle(mp, arg, inode);
809 802
810 case XFS_IOC_ATTRLIST_BY_HANDLE: 803 case XFS_IOC_ATTRLIST_BY_HANDLE:
811 return xfs_attrlist_by_handle(mp, arg, filp, inode); 804 return xfs_attrlist_by_handle(mp, arg, inode);
812 805
813 case XFS_IOC_ATTRMULTI_BY_HANDLE: 806 case XFS_IOC_ATTRMULTI_BY_HANDLE:
814 return xfs_attrmulti_by_handle(mp, arg, filp, inode); 807 return xfs_attrmulti_by_handle(mp, arg, inode);
815 808
816 case XFS_IOC_SWAPEXT: { 809 case XFS_IOC_SWAPEXT: {
817 error = xfs_swapext((struct xfs_swapext __user *)arg); 810 error = xfs_swapext((struct xfs_swapext __user *)arg);
@@ -1095,11 +1088,6 @@ xfs_ioc_fsgeometry(
1095/* 1088/*
1096 * Linux extended inode flags interface. 1089 * Linux extended inode flags interface.
1097 */ 1090 */
1098#define LINUX_XFLAG_SYNC 0x00000008 /* Synchronous updates */
1099#define LINUX_XFLAG_IMMUTABLE 0x00000010 /* Immutable file */
1100#define LINUX_XFLAG_APPEND 0x00000020 /* writes to file may only append */
1101#define LINUX_XFLAG_NODUMP 0x00000040 /* do not dump file */
1102#define LINUX_XFLAG_NOATIME 0x00000080 /* do not update atime */
1103 1091
1104STATIC unsigned int 1092STATIC unsigned int
1105xfs_merge_ioc_xflags( 1093xfs_merge_ioc_xflags(
@@ -1108,23 +1096,23 @@ xfs_merge_ioc_xflags(
1108{ 1096{
1109 unsigned int xflags = start; 1097 unsigned int xflags = start;
1110 1098
1111 if (flags & LINUX_XFLAG_IMMUTABLE) 1099 if (flags & FS_IMMUTABLE_FL)
1112 xflags |= XFS_XFLAG_IMMUTABLE; 1100 xflags |= XFS_XFLAG_IMMUTABLE;
1113 else 1101 else
1114 xflags &= ~XFS_XFLAG_IMMUTABLE; 1102 xflags &= ~XFS_XFLAG_IMMUTABLE;
1115 if (flags & LINUX_XFLAG_APPEND) 1103 if (flags & FS_APPEND_FL)
1116 xflags |= XFS_XFLAG_APPEND; 1104 xflags |= XFS_XFLAG_APPEND;
1117 else 1105 else
1118 xflags &= ~XFS_XFLAG_APPEND; 1106 xflags &= ~XFS_XFLAG_APPEND;
1119 if (flags & LINUX_XFLAG_SYNC) 1107 if (flags & FS_SYNC_FL)
1120 xflags |= XFS_XFLAG_SYNC; 1108 xflags |= XFS_XFLAG_SYNC;
1121 else 1109 else
1122 xflags &= ~XFS_XFLAG_SYNC; 1110 xflags &= ~XFS_XFLAG_SYNC;
1123 if (flags & LINUX_XFLAG_NOATIME) 1111 if (flags & FS_NOATIME_FL)
1124 xflags |= XFS_XFLAG_NOATIME; 1112 xflags |= XFS_XFLAG_NOATIME;
1125 else 1113 else
1126 xflags &= ~XFS_XFLAG_NOATIME; 1114 xflags &= ~XFS_XFLAG_NOATIME;
1127 if (flags & LINUX_XFLAG_NODUMP) 1115 if (flags & FS_NODUMP_FL)
1128 xflags |= XFS_XFLAG_NODUMP; 1116 xflags |= XFS_XFLAG_NODUMP;
1129 else 1117 else
1130 xflags &= ~XFS_XFLAG_NODUMP; 1118 xflags &= ~XFS_XFLAG_NODUMP;
@@ -1139,15 +1127,15 @@ xfs_di2lxflags(
1139 unsigned int flags = 0; 1127 unsigned int flags = 0;
1140 1128
1141 if (di_flags & XFS_DIFLAG_IMMUTABLE) 1129 if (di_flags & XFS_DIFLAG_IMMUTABLE)
1142 flags |= LINUX_XFLAG_IMMUTABLE; 1130 flags |= FS_IMMUTABLE_FL;
1143 if (di_flags & XFS_DIFLAG_APPEND) 1131 if (di_flags & XFS_DIFLAG_APPEND)
1144 flags |= LINUX_XFLAG_APPEND; 1132 flags |= FS_APPEND_FL;
1145 if (di_flags & XFS_DIFLAG_SYNC) 1133 if (di_flags & XFS_DIFLAG_SYNC)
1146 flags |= LINUX_XFLAG_SYNC; 1134 flags |= FS_SYNC_FL;
1147 if (di_flags & XFS_DIFLAG_NOATIME) 1135 if (di_flags & XFS_DIFLAG_NOATIME)
1148 flags |= LINUX_XFLAG_NOATIME; 1136 flags |= FS_NOATIME_FL;
1149 if (di_flags & XFS_DIFLAG_NODUMP) 1137 if (di_flags & XFS_DIFLAG_NODUMP)
1150 flags |= LINUX_XFLAG_NODUMP; 1138 flags |= FS_NODUMP_FL;
1151 return flags; 1139 return flags;
1152} 1140}
1153 1141
@@ -1247,9 +1235,9 @@ xfs_ioc_xattr(
1247 break; 1235 break;
1248 } 1236 }
1249 1237
1250 if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \ 1238 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
1251 LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \ 1239 FS_NOATIME_FL | FS_NODUMP_FL | \
1252 LINUX_XFLAG_SYNC)) { 1240 FS_SYNC_FL)) {
1253 error = -EOPNOTSUPP; 1241 error = -EOPNOTSUPP;
1254 break; 1242 break;
1255 } 1243 }
@@ -1281,7 +1269,6 @@ xfs_ioc_xattr(
1281STATIC int 1269STATIC int
1282xfs_ioc_getbmap( 1270xfs_ioc_getbmap(
1283 bhv_desc_t *bdp, 1271 bhv_desc_t *bdp,
1284 struct file *filp,
1285 int ioflags, 1272 int ioflags,
1286 unsigned int cmd, 1273 unsigned int cmd,
1287 void __user *arg) 1274 void __user *arg)
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 3ba814ae3bba..aa4c3b8cae01 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_utils.h" 48#include "xfs_utils.h"
@@ -250,13 +248,13 @@ xfs_init_security(
250 * 248 *
251 * XXX(hch): nfsd is broken, better fix it instead. 249 * XXX(hch): nfsd is broken, better fix it instead.
252 */ 250 */
253STATIC inline int 251STATIC_INLINE int
254xfs_has_fs_struct(struct task_struct *task) 252xfs_has_fs_struct(struct task_struct *task)
255{ 253{
256 return (task->fs != init_task.fs); 254 return (task->fs != init_task.fs);
257} 255}
258 256
259STATIC inline void 257STATIC void
260xfs_cleanup_inode( 258xfs_cleanup_inode(
261 bhv_vnode_t *dvp, 259 bhv_vnode_t *dvp,
262 bhv_vnode_t *vp, 260 bhv_vnode_t *vp,
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 65e79b471d49..ff8d64eba9f8 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_inode_item.h" 47#include "xfs_inode_item.h"
50#include "xfs_buf_item.h" 48#include "xfs_buf_item.h"
@@ -134,13 +132,11 @@ STATIC int
134xfs_iozero( 132xfs_iozero(
135 struct inode *ip, /* inode */ 133 struct inode *ip, /* inode */
136 loff_t pos, /* offset in file */ 134 loff_t pos, /* offset in file */
137 size_t count, /* size of data to zero */ 135 size_t count) /* size of data to zero */
138 loff_t end_size) /* max file size to set */
139{ 136{
140 unsigned bytes; 137 unsigned bytes;
141 struct page *page; 138 struct page *page;
142 struct address_space *mapping; 139 struct address_space *mapping;
143 char *kaddr;
144 int status; 140 int status;
145 141
146 mapping = ip->i_mapping; 142 mapping = ip->i_mapping;
@@ -158,26 +154,21 @@ xfs_iozero(
158 if (!page) 154 if (!page)
159 break; 155 break;
160 156
161 kaddr = kmap(page);
162 status = mapping->a_ops->prepare_write(NULL, page, offset, 157 status = mapping->a_ops->prepare_write(NULL, page, offset,
163 offset + bytes); 158 offset + bytes);
164 if (status) { 159 if (status)
165 goto unlock; 160 goto unlock;
166 }
167 161
168 memset((void *) (kaddr + offset), 0, bytes); 162 memclear_highpage_flush(page, offset, bytes);
169 flush_dcache_page(page); 163
170 status = mapping->a_ops->commit_write(NULL, page, offset, 164 status = mapping->a_ops->commit_write(NULL, page, offset,
171 offset + bytes); 165 offset + bytes);
172 if (!status) { 166 if (!status) {
173 pos += bytes; 167 pos += bytes;
174 count -= bytes; 168 count -= bytes;
175 if (pos > i_size_read(ip))
176 i_size_write(ip, pos < end_size ? pos : end_size);
177 } 169 }
178 170
179unlock: 171unlock:
180 kunmap(page);
181 unlock_page(page); 172 unlock_page(page);
182 page_cache_release(page); 173 page_cache_release(page);
183 if (status) 174 if (status)
@@ -449,8 +440,8 @@ STATIC int /* error (positive) */
449xfs_zero_last_block( 440xfs_zero_last_block(
450 struct inode *ip, 441 struct inode *ip,
451 xfs_iocore_t *io, 442 xfs_iocore_t *io,
452 xfs_fsize_t isize, 443 xfs_fsize_t offset,
453 xfs_fsize_t end_size) 444 xfs_fsize_t isize)
454{ 445{
455 xfs_fileoff_t last_fsb; 446 xfs_fileoff_t last_fsb;
456 xfs_mount_t *mp = io->io_mount; 447 xfs_mount_t *mp = io->io_mount;
@@ -459,7 +450,6 @@ xfs_zero_last_block(
459 int zero_len; 450 int zero_len;
460 int error = 0; 451 int error = 0;
461 xfs_bmbt_irec_t imap; 452 xfs_bmbt_irec_t imap;
462 loff_t loff;
463 453
464 ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); 454 ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
465 455
@@ -494,9 +484,10 @@ xfs_zero_last_block(
494 */ 484 */
495 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); 485 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
496 486
497 loff = XFS_FSB_TO_B(mp, last_fsb);
498 zero_len = mp->m_sb.sb_blocksize - zero_offset; 487 zero_len = mp->m_sb.sb_blocksize - zero_offset;
499 error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size); 488 if (isize + zero_len > offset)
489 zero_len = offset - isize;
490 error = xfs_iozero(ip, isize, zero_len);
500 491
501 XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); 492 XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
502 ASSERT(error >= 0); 493 ASSERT(error >= 0);
@@ -519,14 +510,15 @@ xfs_zero_eof(
519 bhv_vnode_t *vp, 510 bhv_vnode_t *vp,
520 xfs_iocore_t *io, 511 xfs_iocore_t *io,
521 xfs_off_t offset, /* starting I/O offset */ 512 xfs_off_t offset, /* starting I/O offset */
522 xfs_fsize_t isize, /* current inode size */ 513 xfs_fsize_t isize) /* current inode size */
523 xfs_fsize_t end_size) /* terminal inode size */
524{ 514{
525 struct inode *ip = vn_to_inode(vp); 515 struct inode *ip = vn_to_inode(vp);
526 xfs_fileoff_t start_zero_fsb; 516 xfs_fileoff_t start_zero_fsb;
527 xfs_fileoff_t end_zero_fsb; 517 xfs_fileoff_t end_zero_fsb;
528 xfs_fileoff_t zero_count_fsb; 518 xfs_fileoff_t zero_count_fsb;
529 xfs_fileoff_t last_fsb; 519 xfs_fileoff_t last_fsb;
520 xfs_fileoff_t zero_off;
521 xfs_fsize_t zero_len;
530 xfs_mount_t *mp = io->io_mount; 522 xfs_mount_t *mp = io->io_mount;
531 int nimaps; 523 int nimaps;
532 int error = 0; 524 int error = 0;
@@ -540,7 +532,7 @@ xfs_zero_eof(
540 * First handle zeroing the block on which isize resides. 532 * First handle zeroing the block on which isize resides.
541 * We only zero a part of that block so it is handled specially. 533 * We only zero a part of that block so it is handled specially.
542 */ 534 */
543 error = xfs_zero_last_block(ip, io, isize, end_size); 535 error = xfs_zero_last_block(ip, io, offset, isize);
544 if (error) { 536 if (error) {
545 ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); 537 ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
546 ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); 538 ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
@@ -601,10 +593,13 @@ xfs_zero_eof(
601 */ 593 */
602 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); 594 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
603 595
604 error = xfs_iozero(ip, 596 zero_off = XFS_FSB_TO_B(mp, start_zero_fsb);
605 XFS_FSB_TO_B(mp, start_zero_fsb), 597 zero_len = XFS_FSB_TO_B(mp, imap.br_blockcount);
606 XFS_FSB_TO_B(mp, imap.br_blockcount), 598
607 end_size); 599 if ((zero_off + zero_len) > offset)
600 zero_len = offset - zero_off;
601
602 error = xfs_iozero(ip, zero_off, zero_len);
608 if (error) { 603 if (error) {
609 goto out_lock; 604 goto out_lock;
610 } 605 }
@@ -783,8 +778,7 @@ start:
783 */ 778 */
784 779
785 if (pos > isize) { 780 if (pos > isize) {
786 error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, 781 error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, isize);
787 isize, pos + count);
788 if (error) { 782 if (error) {
789 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 783 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
790 goto out_unlock_mutex; 784 goto out_unlock_mutex;
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index c77e62efb742..7ac51b1d2161 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -83,7 +83,7 @@ extern int xfs_bdstrat_cb(struct xfs_buf *);
83extern int xfs_dev_is_read_only(struct xfs_mount *, char *); 83extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
84 84
85extern int xfs_zero_eof(struct bhv_vnode *, struct xfs_iocore *, xfs_off_t, 85extern int xfs_zero_eof(struct bhv_vnode *, struct xfs_iocore *, xfs_off_t,
86 xfs_fsize_t, xfs_fsize_t); 86 xfs_fsize_t);
87extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *, 87extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
88 const struct iovec *, unsigned int, 88 const struct iovec *, unsigned int,
89 loff_t *, int, struct cred *); 89 loff_t *, int, struct cred *);
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index b93265b7c79c..1a4103ca593c 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_utils.h" 48#include "xfs_utils.h"
@@ -58,10 +56,10 @@
58#include <linux/kthread.h> 56#include <linux/kthread.h>
59#include <linux/freezer.h> 57#include <linux/freezer.h>
60 58
61STATIC struct quotactl_ops xfs_quotactl_operations; 59static struct quotactl_ops xfs_quotactl_operations;
62STATIC struct super_operations xfs_super_operations; 60static struct super_operations xfs_super_operations;
63STATIC kmem_zone_t *xfs_vnode_zone; 61static kmem_zone_t *xfs_vnode_zone;
64STATIC kmem_zone_t *xfs_ioend_zone; 62static kmem_zone_t *xfs_ioend_zone;
65mempool_t *xfs_ioend_pool; 63mempool_t *xfs_ioend_pool;
66 64
67STATIC struct xfs_mount_args * 65STATIC struct xfs_mount_args *
@@ -121,7 +119,7 @@ xfs_max_file_offset(
121 return (((__uint64_t)pagefactor) << bitshift) - 1; 119 return (((__uint64_t)pagefactor) << bitshift) - 1;
122} 120}
123 121
124STATIC __inline__ void 122STATIC_INLINE void
125xfs_set_inodeops( 123xfs_set_inodeops(
126 struct inode *inode) 124 struct inode *inode)
127{ 125{
@@ -147,7 +145,7 @@ xfs_set_inodeops(
147 } 145 }
148} 146}
149 147
150STATIC __inline__ void 148STATIC_INLINE void
151xfs_revalidate_inode( 149xfs_revalidate_inode(
152 xfs_mount_t *mp, 150 xfs_mount_t *mp,
153 bhv_vnode_t *vp, 151 bhv_vnode_t *vp,
@@ -553,7 +551,6 @@ vfs_sync_worker(
553 error = bhv_vfs_sync(vfsp, SYNC_FSDATA | SYNC_BDFLUSH | \ 551 error = bhv_vfs_sync(vfsp, SYNC_FSDATA | SYNC_BDFLUSH | \
554 SYNC_ATTR | SYNC_REFCACHE, NULL); 552 SYNC_ATTR | SYNC_REFCACHE, NULL);
555 vfsp->vfs_sync_seq++; 553 vfsp->vfs_sync_seq++;
556 wmb();
557 wake_up(&vfsp->vfs_wait_single_sync_task); 554 wake_up(&vfsp->vfs_wait_single_sync_task);
558} 555}
559 556
@@ -659,9 +656,17 @@ xfs_fs_sync_super(
659 int error; 656 int error;
660 int flags; 657 int flags;
661 658
662 if (unlikely(sb->s_frozen == SB_FREEZE_WRITE)) 659 if (unlikely(sb->s_frozen == SB_FREEZE_WRITE)) {
663 flags = SYNC_QUIESCE; 660 /*
664 else 661 * First stage of freeze - no more writers will make progress
662 * now we are here, so we flush delwri and delalloc buffers
663 * here, then wait for all I/O to complete. Data is frozen at
664 * that point. Metadata is not frozen, transactions can still
665 * occur here so don't bother flushing the buftarg (i.e
666 * SYNC_QUIESCE) because it'll just get dirty again.
667 */
668 flags = SYNC_FSDATA | SYNC_DELWRI | SYNC_WAIT | SYNC_IOWAIT;
669 } else
665 flags = SYNC_FSDATA | (wait ? SYNC_WAIT : 0); 670 flags = SYNC_FSDATA | (wait ? SYNC_WAIT : 0);
666 671
667 error = bhv_vfs_sync(vfsp, flags, NULL); 672 error = bhv_vfs_sync(vfsp, flags, NULL);
@@ -873,7 +878,7 @@ xfs_fs_get_sb(
873 mnt); 878 mnt);
874} 879}
875 880
876STATIC struct super_operations xfs_super_operations = { 881static struct super_operations xfs_super_operations = {
877 .alloc_inode = xfs_fs_alloc_inode, 882 .alloc_inode = xfs_fs_alloc_inode,
878 .destroy_inode = xfs_fs_destroy_inode, 883 .destroy_inode = xfs_fs_destroy_inode,
879 .write_inode = xfs_fs_write_inode, 884 .write_inode = xfs_fs_write_inode,
@@ -887,7 +892,7 @@ STATIC struct super_operations xfs_super_operations = {
887 .show_options = xfs_fs_show_options, 892 .show_options = xfs_fs_show_options,
888}; 893};
889 894
890STATIC struct quotactl_ops xfs_quotactl_operations = { 895static struct quotactl_ops xfs_quotactl_operations = {
891 .quota_sync = xfs_fs_quotasync, 896 .quota_sync = xfs_fs_quotasync,
892 .get_xstate = xfs_fs_getxstate, 897 .get_xstate = xfs_fs_getxstate,
893 .set_xstate = xfs_fs_setxstate, 898 .set_xstate = xfs_fs_setxstate,
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index af246532fbfb..5c46c35a97a5 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -54,102 +54,204 @@ xfs_stats_clear_proc_handler(
54} 54}
55#endif /* CONFIG_PROC_FS */ 55#endif /* CONFIG_PROC_FS */
56 56
57STATIC ctl_table xfs_table[] = { 57static ctl_table xfs_table[] = {
58 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, 58 {
59 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 59 .ctl_name = XFS_RESTRICT_CHOWN,
60 &sysctl_intvec, NULL, 60 .procname = "restrict_chown",
61 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, 61 .data = &xfs_params.restrict_chown.val,
62 62 .maxlen = sizeof(int),
63 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, 63 .mode = 0644,
64 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 64 .proc_handler = &proc_dointvec_minmax,
65 &sysctl_intvec, NULL, 65 .strategy = &sysctl_intvec,
66 &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max}, 66 .extra1 = &xfs_params.restrict_chown.min,
67 67 .extra2 = &xfs_params.restrict_chown.max
68 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, 68 },
69 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 69 {
70 &sysctl_intvec, NULL, 70 .ctl_name = XFS_SGID_INHERIT,
71 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, 71 .procname = "irix_sgid_inherit",
72 72 .data = &xfs_params.sgid_inherit.val,
73 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, 73 .maxlen = sizeof(int),
74 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 74 .mode = 0644,
75 &sysctl_intvec, NULL, 75 .proc_handler = &proc_dointvec_minmax,
76 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, 76 .strategy = &sysctl_intvec,
77 77 .extra1 = &xfs_params.sgid_inherit.min,
78 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, 78 .extra2 = &xfs_params.sgid_inherit.max
79 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 79 },
80 &sysctl_intvec, NULL, 80 {
81 &xfs_params.error_level.min, &xfs_params.error_level.max}, 81 .ctl_name = XFS_SYMLINK_MODE,
82 82 .procname = "irix_symlink_mode",
83 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, 83 .data = &xfs_params.symlink_mode.val,
84 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 84 .maxlen = sizeof(int),
85 &sysctl_intvec, NULL, 85 .mode = 0644,
86 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, 86 .proc_handler = &proc_dointvec_minmax,
87 87 .strategy = &sysctl_intvec,
88 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, 88 .extra1 = &xfs_params.symlink_mode.min,
89 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 89 .extra2 = &xfs_params.symlink_mode.max
90 &sysctl_intvec, NULL, 90 },
91 &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max}, 91 {
92 92 .ctl_name = XFS_PANIC_MASK,
93 {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val, 93 .procname = "panic_mask",
94 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 94 .data = &xfs_params.panic_mask.val,
95 &sysctl_intvec, NULL, 95 .maxlen = sizeof(int),
96 &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max}, 96 .mode = 0644,
97 97 .proc_handler = &proc_dointvec_minmax,
98 {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val, 98 .strategy = &sysctl_intvec,
99 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 99 .extra1 = &xfs_params.panic_mask.min,
100 &sysctl_intvec, NULL, 100 .extra2 = &xfs_params.panic_mask.max
101 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, 101 },
102
103 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
104 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
105 &sysctl_intvec, NULL,
106 &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
107
108 {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
109 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
110 &sysctl_intvec, NULL,
111 &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
112
113 {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val,
114 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
115 &sysctl_intvec, NULL,
116 &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
117
118 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
119 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
120 &sysctl_intvec, NULL,
121 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
122
123 {XFS_INHERIT_NODFRG, "inherit_nodefrag", &xfs_params.inherit_nodfrg.val,
124 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
125 &sysctl_intvec, NULL,
126 &xfs_params.inherit_nodfrg.min, &xfs_params.inherit_nodfrg.max},
127 102
103 {
104 .ctl_name = XFS_ERRLEVEL,
105 .procname = "error_level",
106 .data = &xfs_params.error_level.val,
107 .maxlen = sizeof(int),
108 .mode = 0644,
109 .proc_handler = &proc_dointvec_minmax,
110 .strategy = &sysctl_intvec,
111 .extra1 = &xfs_params.error_level.min,
112 .extra2 = &xfs_params.error_level.max
113 },
114 {
115 .ctl_name = XFS_SYNCD_TIMER,
116 .procname = "xfssyncd_centisecs",
117 .data = &xfs_params.syncd_timer.val,
118 .maxlen = sizeof(int),
119 .mode = 0644,
120 .proc_handler = &proc_dointvec_minmax,
121 .strategy = &sysctl_intvec,
122 .extra1 = &xfs_params.syncd_timer.min,
123 .extra2 = &xfs_params.syncd_timer.max
124 },
125 {
126 .ctl_name = XFS_INHERIT_SYNC,
127 .procname = "inherit_sync",
128 .data = &xfs_params.inherit_sync.val,
129 .maxlen = sizeof(int),
130 .mode = 0644,
131 .proc_handler = &proc_dointvec_minmax,
132 .strategy = &sysctl_intvec,
133 .extra1 = &xfs_params.inherit_sync.min,
134 .extra2 = &xfs_params.inherit_sync.max
135 },
136 {
137 .ctl_name = XFS_INHERIT_NODUMP,
138 .procname = "inherit_nodump",
139 .data = &xfs_params.inherit_nodump.val,
140 .maxlen = sizeof(int),
141 .mode = 0644,
142 .proc_handler = &proc_dointvec_minmax,
143 .strategy = &sysctl_intvec,
144 .extra1 = &xfs_params.inherit_nodump.min,
145 .extra2 = &xfs_params.inherit_nodump.max
146 },
147 {
148 .ctl_name = XFS_INHERIT_NOATIME,
149 .procname = "inherit_noatime",
150 .data = &xfs_params.inherit_noatim.val,
151 .maxlen = sizeof(int),
152 .mode = 0644,
153 .proc_handler = &proc_dointvec_minmax,
154 .strategy = &sysctl_intvec,
155 .extra1 = &xfs_params.inherit_noatim.min,
156 .extra2 = &xfs_params.inherit_noatim.max
157 },
158 {
159 .ctl_name = XFS_BUF_TIMER,
160 .procname = "xfsbufd_centisecs",
161 .data = &xfs_params.xfs_buf_timer.val,
162 .maxlen = sizeof(int),
163 .mode = 0644,
164 .proc_handler = &proc_dointvec_minmax,
165 .strategy = &sysctl_intvec,
166 .extra1 = &xfs_params.xfs_buf_timer.min,
167 .extra2 = &xfs_params.xfs_buf_timer.max
168 },
169 {
170 .ctl_name = XFS_BUF_AGE,
171 .procname = "age_buffer_centisecs",
172 .data = &xfs_params.xfs_buf_age.val,
173 .maxlen = sizeof(int),
174 .mode = 0644,
175 .proc_handler = &proc_dointvec_minmax,
176 .strategy = &sysctl_intvec,
177 .extra1 = &xfs_params.xfs_buf_age.min,
178 .extra2 = &xfs_params.xfs_buf_age.max
179 },
180 {
181 .ctl_name = XFS_INHERIT_NOSYM,
182 .procname = "inherit_nosymlinks",
183 .data = &xfs_params.inherit_nosym.val,
184 .maxlen = sizeof(int),
185 .mode = 0644,
186 .proc_handler = &proc_dointvec_minmax,
187 .strategy = &sysctl_intvec,
188 .extra1 = &xfs_params.inherit_nosym.min,
189 .extra2 = &xfs_params.inherit_nosym.max
190 },
191 {
192 .ctl_name = XFS_ROTORSTEP,
193 .procname = "rotorstep",
194 .data = &xfs_params.rotorstep.val,
195 .maxlen = sizeof(int),
196 .mode = 0644,
197 .proc_handler = &proc_dointvec_minmax,
198 .strategy = &sysctl_intvec,
199 .extra1 = &xfs_params.rotorstep.min,
200 .extra2 = &xfs_params.rotorstep.max
201 },
202 {
203 .ctl_name = XFS_INHERIT_NODFRG,
204 .procname = "inherit_nodefrag",
205 .data = &xfs_params.inherit_nodfrg.val,
206 .maxlen = sizeof(int),
207 .mode = 0644,
208 .proc_handler = &proc_dointvec_minmax,
209 .strategy = &sysctl_intvec,
210 .extra1 = &xfs_params.inherit_nodfrg.min,
211 .extra2 = &xfs_params.inherit_nodfrg.max
212 },
128 /* please keep this the last entry */ 213 /* please keep this the last entry */
129#ifdef CONFIG_PROC_FS 214#ifdef CONFIG_PROC_FS
130 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, 215 {
131 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, 216 .ctl_name = XFS_STATS_CLEAR,
132 &sysctl_intvec, NULL, 217 .procname = "stats_clear",
133 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, 218 .data = &xfs_params.stats_clear.val,
219 .maxlen = sizeof(int),
220 .mode = 0644,
221 .proc_handler = &xfs_stats_clear_proc_handler,
222 .strategy = &sysctl_intvec,
223 .extra1 = &xfs_params.stats_clear.min,
224 .extra2 = &xfs_params.stats_clear.max
225 },
134#endif /* CONFIG_PROC_FS */ 226#endif /* CONFIG_PROC_FS */
135 227
136 {0} 228 {}
137}; 229};
138 230
139STATIC ctl_table xfs_dir_table[] = { 231static ctl_table xfs_dir_table[] = {
140 {FS_XFS, "xfs", NULL, 0, 0555, xfs_table}, 232 {
141 {0} 233 .ctl_name = FS_XFS,
234 .procname = "xfs",
235 .mode = 0555,
236 .child = xfs_table
237 },
238 {}
142}; 239};
143 240
144STATIC ctl_table xfs_root_table[] = { 241static ctl_table xfs_root_table[] = {
145 {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table}, 242 {
146 {0} 243 .ctl_name = CTL_FS,
244 .procname = "fs",
245 .mode = 0555,
246 .child = xfs_dir_table
247 },
248 {}
147}; 249};
148 250
149void 251void
150xfs_sysctl_register(void) 252xfs_sysctl_register(void)
151{ 253{
152 xfs_table_header = register_sysctl_table(xfs_root_table, 1); 254 xfs_table_header = register_sysctl_table(xfs_root_table, 0);
153} 255}
154 256
155void 257void
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index da255bdf5260..e2c2ce98ab5b 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -91,7 +91,7 @@ typedef enum {
91#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */ 91#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
92#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ 92#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
93#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ 93#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
94#define SYNC_QUIESCE 0x0100 /* quiesce fileystem for a snapshot */ 94#define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */
95 95
96#define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */ 96#define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */
97#define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */ 97#define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 553fa731ade5..ada24baf88de 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -26,7 +26,7 @@ DEFINE_SPINLOCK(vnumber_lock);
26 */ 26 */
27#define NVSYNC 37 27#define NVSYNC 37
28#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) 28#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
29STATIC wait_queue_head_t vsync[NVSYNC]; 29static wait_queue_head_t vsync[NVSYNC];
30 30
31void 31void
32vn_init(void) 32vn_init(void)
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 515f5fdea57a..b76118cf4897 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -489,14 +489,14 @@ static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp)
489#define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock) 489#define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock)
490#define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s) 490#define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s)
491 491
492static __inline__ void vn_flagset(struct bhv_vnode *vp, uint flag) 492STATIC_INLINE void vn_flagset(struct bhv_vnode *vp, uint flag)
493{ 493{
494 spin_lock(&vp->v_lock); 494 spin_lock(&vp->v_lock);
495 vp->v_flag |= flag; 495 vp->v_flag |= flag;
496 spin_unlock(&vp->v_lock); 496 spin_unlock(&vp->v_lock);
497} 497}
498 498
499static __inline__ uint vn_flagclr(struct bhv_vnode *vp, uint flag) 499STATIC_INLINE uint vn_flagclr(struct bhv_vnode *vp, uint flag)
500{ 500{
501 uint cleared; 501 uint cleared;
502 502
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 3aa771531856..4adaf13aac6f 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_trans_space.h" 48#include "xfs_trans_space.h"
@@ -484,7 +482,7 @@ xfs_qm_dqalloc(
484 482
485 xfs_trans_bhold(tp, bp); 483 xfs_trans_bhold(tp, bp);
486 484
487 if ((error = xfs_bmap_finish(tpp, &flist, firstblock, &committed))) { 485 if ((error = xfs_bmap_finish(tpp, &flist, &committed))) {
488 goto error1; 486 goto error1;
489 } 487 }
490 488
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index 33ad5af386e0..ddb61fe22a5c 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_trans_priv.h" 48#include "xfs_trans_priv.h"
@@ -399,7 +397,7 @@ xfs_qm_dquot_logitem_committing(
399/* 397/*
400 * This is the ops vector for dquots 398 * This is the ops vector for dquots
401 */ 399 */
402STATIC struct xfs_item_ops xfs_dquot_item_ops = { 400static struct xfs_item_ops xfs_dquot_item_ops = {
403 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size, 401 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size,
404 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 402 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
405 xfs_qm_dquot_logitem_format, 403 xfs_qm_dquot_logitem_format,
@@ -606,7 +604,7 @@ xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
606 return; 604 return;
607} 605}
608 606
609STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { 607static struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
610 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 608 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
611 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 609 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
612 xfs_qm_qoff_logitem_format, 610 xfs_qm_qoff_logitem_format,
@@ -628,7 +626,7 @@ STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
628/* 626/*
629 * This is the ops vector shared by all quotaoff-start log items. 627 * This is the ops vector shared by all quotaoff-start log items.
630 */ 628 */
631STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = { 629static struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
632 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 630 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
633 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 631 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
634 xfs_qm_qoff_logitem_format, 632 xfs_qm_qoff_logitem_format,
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 7c6a3a50379e..1de2acdc7f70 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -44,8 +44,6 @@
44#include "xfs_bmap.h" 44#include "xfs_bmap.h"
45#include "xfs_rw.h" 45#include "xfs_rw.h"
46#include "xfs_acl.h" 46#include "xfs_acl.h"
47#include "xfs_cap.h"
48#include "xfs_mac.h"
49#include "xfs_attr.h" 47#include "xfs_attr.h"
50#include "xfs_buf_item.h" 48#include "xfs_buf_item.h"
51#include "xfs_trans_space.h" 49#include "xfs_trans_space.h"
@@ -64,10 +62,10 @@ uint ndquot;
64 62
65kmem_zone_t *qm_dqzone; 63kmem_zone_t *qm_dqzone;
66kmem_zone_t *qm_dqtrxzone; 64kmem_zone_t *qm_dqtrxzone;
67STATIC kmem_shaker_t xfs_qm_shaker; 65static kmem_shaker_t xfs_qm_shaker;
68 66
69STATIC cred_t xfs_zerocr; 67static cred_t xfs_zerocr;
70STATIC xfs_inode_t xfs_zeroino; 68static xfs_inode_t xfs_zeroino;
71 69
72STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); 70STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int);
73STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); 71STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
index db8872be8c87..d2cdb8a2aad6 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/quota/xfs_qm_bhv.c
@@ -44,8 +44,6 @@
44#include "xfs_error.h" 44#include "xfs_error.h"
45#include "xfs_rw.h" 45#include "xfs_rw.h"
46#include "xfs_acl.h" 46#include "xfs_acl.h"
47#include "xfs_cap.h"
48#include "xfs_mac.h"
49#include "xfs_attr.h" 47#include "xfs_attr.h"
50#include "xfs_buf_item.h" 48#include "xfs_buf_item.h"
51#include "xfs_qm.h" 49#include "xfs_qm.h"
@@ -384,7 +382,7 @@ xfs_qm_dqrele_null(
384} 382}
385 383
386 384
387STATIC struct xfs_qmops xfs_qmcore_xfs = { 385static struct xfs_qmops xfs_qmcore_xfs = {
388 .xfs_qminit = xfs_qm_newmount, 386 .xfs_qminit = xfs_qm_newmount,
389 .xfs_qmdone = xfs_qm_unmount_quotadestroy, 387 .xfs_qmdone = xfs_qm_unmount_quotadestroy,
390 .xfs_qmmount = xfs_qm_endmount, 388 .xfs_qmmount = xfs_qm_endmount,
diff --git a/fs/xfs/quota/xfs_qm_stats.c b/fs/xfs/quota/xfs_qm_stats.c
index 6f858fb81a36..709f5f545cf5 100644
--- a/fs/xfs/quota/xfs_qm_stats.c
+++ b/fs/xfs/quota/xfs_qm_stats.c
@@ -43,8 +43,6 @@
43#include "xfs_error.h" 43#include "xfs_error.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_qm.h" 48#include "xfs_qm.h"
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index ed620c4d1594..716f562aa8b2 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -46,8 +46,6 @@
46#include "xfs_error.h" 46#include "xfs_error.h"
47#include "xfs_rw.h" 47#include "xfs_rw.h"
48#include "xfs_acl.h" 48#include "xfs_acl.h"
49#include "xfs_cap.h"
50#include "xfs_mac.h"
51#include "xfs_attr.h" 49#include "xfs_attr.h"
52#include "xfs_buf_item.h" 50#include "xfs_buf_item.h"
53#include "xfs_utils.h" 51#include "xfs_utils.h"
@@ -134,7 +132,7 @@ xfs_qm_quotactl(
134 break; 132 break;
135 133
136 case Q_XQUOTASYNC: 134 case Q_XQUOTASYNC:
137 return (xfs_sync_inodes(mp, SYNC_DELWRI, 0, NULL)); 135 return (xfs_sync_inodes(mp, SYNC_DELWRI, NULL));
138 136
139 default: 137 default:
140 break; 138 break;
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index 0242e9666e8e..d7491e7b1f3b 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -43,8 +43,6 @@
43#include "xfs_error.h" 43#include "xfs_error.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_trans_priv.h" 48#include "xfs_trans_priv.h"
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c
index 4363512d2f90..08bbd3cb87ae 100644
--- a/fs/xfs/support/debug.c
+++ b/fs/xfs/support/debug.c
@@ -19,7 +19,7 @@
19#include "debug.h" 19#include "debug.h"
20#include "spin.h" 20#include "spin.h"
21 21
22static char message[256]; /* keep it off the stack */ 22static char message[1024]; /* keep it off the stack */
23static DEFINE_SPINLOCK(xfs_err_lock); 23static DEFINE_SPINLOCK(xfs_err_lock);
24 24
25/* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */ 25/* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
@@ -44,13 +44,14 @@ cmn_err(register int level, char *fmt, ...)
44 spin_lock_irqsave(&xfs_err_lock,flags); 44 spin_lock_irqsave(&xfs_err_lock,flags);
45 va_start(ap, fmt); 45 va_start(ap, fmt);
46 if (*fmt == '!') fp++; 46 if (*fmt == '!') fp++;
47 len = vsprintf(message, fp, ap); 47 len = vsnprintf(message, sizeof(message), fp, ap);
48 if (level != CE_DEBUG && message[len-1] != '\n') 48 if (len >= sizeof(message))
49 strcat(message, "\n"); 49 len = sizeof(message) - 1;
50 printk("%s%s", err_level[level], message); 50 if (message[len-1] == '\n')
51 message[len-1] = 0;
52 printk("%s%s\n", err_level[level], message);
51 va_end(ap); 53 va_end(ap);
52 spin_unlock_irqrestore(&xfs_err_lock,flags); 54 spin_unlock_irqrestore(&xfs_err_lock,flags);
53
54 BUG_ON(level == CE_PANIC); 55 BUG_ON(level == CE_PANIC);
55} 56}
56 57
@@ -64,11 +65,13 @@ icmn_err(register int level, char *fmt, va_list ap)
64 if(level > XFS_MAX_ERR_LEVEL) 65 if(level > XFS_MAX_ERR_LEVEL)
65 level = XFS_MAX_ERR_LEVEL; 66 level = XFS_MAX_ERR_LEVEL;
66 spin_lock_irqsave(&xfs_err_lock,flags); 67 spin_lock_irqsave(&xfs_err_lock,flags);
67 len = vsprintf(message, fmt, ap); 68 len = vsnprintf(message, sizeof(message), fmt, ap);
68 if (level != CE_DEBUG && message[len-1] != '\n') 69 if (len >= sizeof(message))
69 strcat(message, "\n"); 70 len = sizeof(message) - 1;
71 if (message[len-1] == '\n')
72 message[len-1] = 0;
73 printk("%s%s\n", err_level[level], message);
70 spin_unlock_irqrestore(&xfs_err_lock,flags); 74 spin_unlock_irqrestore(&xfs_err_lock,flags);
71 printk("%s%s", err_level[level], message);
72 BUG_ON(level == CE_PANIC); 75 BUG_ON(level == CE_PANIC);
73} 76}
74 77
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h
index 4f54dca662a8..2a70cc605ae3 100644
--- a/fs/xfs/support/debug.h
+++ b/fs/xfs/support/debug.h
@@ -38,13 +38,37 @@ extern void assfail(char *expr, char *f, int l);
38 38
39#ifndef DEBUG 39#ifndef DEBUG
40# define ASSERT(expr) ((void)0) 40# define ASSERT(expr) ((void)0)
41#else 41
42#ifndef STATIC
43# define STATIC static noinline
44#endif
45
46#ifndef STATIC_INLINE
47# define STATIC_INLINE static inline
48#endif
49
50#else /* DEBUG */
51
42# define ASSERT(expr) ASSERT_ALWAYS(expr) 52# define ASSERT(expr) ASSERT_ALWAYS(expr)
43extern unsigned long random(void); 53extern unsigned long random(void);
44#endif
45 54
46#ifndef STATIC 55#ifndef STATIC
47# define STATIC static 56# define STATIC noinline
48#endif 57#endif
49 58
59/*
60 * We stop inlining of inline functions in debug mode.
61 * Unfortunately, this means static inline in header files
62 * get multiple definitions, so they need to remain static.
63 * This then gives tonnes of warnings about unused but defined
64 * functions, so we need to add the unused attribute to prevent
65 * these spurious warnings.
66 */
67#ifndef STATIC_INLINE
68# define STATIC_INLINE static __attribute__ ((unused)) noinline
69#endif
70
71#endif /* DEBUG */
72
73
50#endif /* __XFS_SUPPORT_DEBUG_H__ */ 74#endif /* __XFS_SUPPORT_DEBUG_H__ */
diff --git a/fs/xfs/support/move.h b/fs/xfs/support/move.h
index 977879c24ff5..324e413deadd 100644
--- a/fs/xfs/support/move.h
+++ b/fs/xfs/support/move.h
@@ -55,7 +55,7 @@ enum uio_seg {
55}; 55};
56 56
57struct uio { 57struct uio {
58 struct iovec *uio_iov; /* pointer to array of iovecs */ 58 struct kvec *uio_iov; /* pointer to array of iovecs */
59 int uio_iovcnt; /* number of iovecs in array */ 59 int uio_iovcnt; /* number of iovecs in array */
60 xfs_off_t uio_offset; /* offset in file this uio corresponds to */ 60 xfs_off_t uio_offset; /* offset in file this uio corresponds to */
61 int uio_resid; /* residual i/o count */ 61 int uio_resid; /* residual i/o count */
@@ -63,7 +63,7 @@ struct uio {
63}; 63};
64 64
65typedef struct uio uio_t; 65typedef struct uio uio_t;
66typedef struct iovec iovec_t; 66typedef struct kvec iovec_t;
67 67
68extern int xfs_uio_read (caddr_t, size_t, uio_t *); 68extern int xfs_uio_read (caddr_t, size_t, uio_t *);
69 69
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 4b0cb474be4c..4ca4beb7bb54 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -31,7 +31,6 @@
31#include "xfs_inode.h" 31#include "xfs_inode.h"
32#include "xfs_btree.h" 32#include "xfs_btree.h"
33#include "xfs_acl.h" 33#include "xfs_acl.h"
34#include "xfs_mac.h"
35#include "xfs_attr.h" 34#include "xfs_attr.h"
36 35
37#include <linux/capability.h> 36#include <linux/capability.h>
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index bce81c7a4fdc..5bd1a2c8bd07 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -58,7 +58,6 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t;
58/* 58/*
59 * Real block structures have a size equal to the disk block size. 59 * Real block structures have a size equal to the disk block size.
60 */ 60 */
61#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
62#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0]) 61#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0])
63#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0]) 62#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0])
64 63
@@ -87,16 +86,13 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t;
87 * Record, key, and pointer address macros for btree blocks. 86 * Record, key, and pointer address macros for btree blocks.
88 */ 87 */
89#define XFS_ALLOC_REC_ADDR(bb,i,cur) \ 88#define XFS_ALLOC_REC_ADDR(bb,i,cur) \
90 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \ 89 XFS_BTREE_REC_ADDR(xfs_alloc, bb, i)
91 bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur))
92 90
93#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ 91#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
94 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \ 92 XFS_BTREE_KEY_ADDR(xfs_alloc, bb, i)
95 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
96 93
97#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ 94#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
98 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \ 95 XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
99 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
100 96
101/* 97/*
102 * Decrement cursor by one record at the level. 98 * Decrement cursor by one record at the level.
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 9ada7bdbae52..9d358ffce4e5 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -57,9 +57,9 @@
57 */ 57 */
58 58
59#define ATTR_SYSCOUNT 2 59#define ATTR_SYSCOUNT 2
60STATIC struct attrnames posix_acl_access; 60static struct attrnames posix_acl_access;
61STATIC struct attrnames posix_acl_default; 61static struct attrnames posix_acl_default;
62STATIC struct attrnames *attr_system_names[ATTR_SYSCOUNT]; 62static struct attrnames *attr_system_names[ATTR_SYSCOUNT];
63 63
64/*======================================================================== 64/*========================================================================
65 * Function prototypes for the kernel. 65 * Function prototypes for the kernel.
@@ -199,18 +199,14 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
199 return (error); 199 return (error);
200 200
201 /* 201 /*
202 * Determine space new attribute will use, and if it would be
203 * "local" or "remote" (note: local != inline).
204 */
205 size = xfs_attr_leaf_newentsize(namelen, valuelen,
206 mp->m_sb.sb_blocksize, &local);
207
208 /*
209 * If the inode doesn't have an attribute fork, add one. 202 * If the inode doesn't have an attribute fork, add one.
210 * (inode must not be locked when we call this routine) 203 * (inode must not be locked when we call this routine)
211 */ 204 */
212 if (XFS_IFORK_Q(dp) == 0) { 205 if (XFS_IFORK_Q(dp) == 0) {
213 if ((error = xfs_bmap_add_attrfork(dp, size, rsvd))) 206 int sf_size = sizeof(xfs_attr_sf_hdr_t) +
207 XFS_ATTR_SF_ENTSIZE_BYNAME(namelen, valuelen);
208
209 if ((error = xfs_bmap_add_attrfork(dp, sf_size, rsvd)))
214 return(error); 210 return(error);
215 } 211 }
216 212
@@ -231,6 +227,13 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
231 args.addname = 1; 227 args.addname = 1;
232 args.oknoent = 1; 228 args.oknoent = 1;
233 229
230 /*
231 * Determine space new attribute will use, and if it would be
232 * "local" or "remote" (note: local != inline).
233 */
234 size = xfs_attr_leaf_newentsize(namelen, valuelen,
235 mp->m_sb.sb_blocksize, &local);
236
234 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); 237 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
235 if (local) { 238 if (local) {
236 if (size > (mp->m_sb.sb_blocksize >> 1)) { 239 if (size > (mp->m_sb.sb_blocksize >> 1)) {
@@ -346,7 +349,7 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
346 error = xfs_attr_shortform_to_leaf(&args); 349 error = xfs_attr_shortform_to_leaf(&args);
347 if (!error) { 350 if (!error) {
348 error = xfs_bmap_finish(&args.trans, args.flist, 351 error = xfs_bmap_finish(&args.trans, args.flist,
349 *args.firstblock, &committed); 352 &committed);
350 } 353 }
351 if (error) { 354 if (error) {
352 ASSERT(committed); 355 ASSERT(committed);
@@ -973,7 +976,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
973 error = xfs_attr_leaf_to_node(args); 976 error = xfs_attr_leaf_to_node(args);
974 if (!error) { 977 if (!error) {
975 error = xfs_bmap_finish(&args->trans, args->flist, 978 error = xfs_bmap_finish(&args->trans, args->flist,
976 *args->firstblock, &committed); 979 &committed);
977 } 980 }
978 if (error) { 981 if (error) {
979 ASSERT(committed); 982 ASSERT(committed);
@@ -1074,7 +1077,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
1074 if (!error) { 1077 if (!error) {
1075 error = xfs_bmap_finish(&args->trans, 1078 error = xfs_bmap_finish(&args->trans,
1076 args->flist, 1079 args->flist,
1077 *args->firstblock,
1078 &committed); 1080 &committed);
1079 } 1081 }
1080 if (error) { 1082 if (error) {
@@ -1152,7 +1154,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1152 /* bp is gone due to xfs_da_shrink_inode */ 1154 /* bp is gone due to xfs_da_shrink_inode */
1153 if (!error) { 1155 if (!error) {
1154 error = xfs_bmap_finish(&args->trans, args->flist, 1156 error = xfs_bmap_finish(&args->trans, args->flist,
1155 *args->firstblock, &committed); 1157 &committed);
1156 } 1158 }
1157 if (error) { 1159 if (error) {
1158 ASSERT(committed); 1160 ASSERT(committed);
@@ -1307,7 +1309,6 @@ restart:
1307 if (!error) { 1309 if (!error) {
1308 error = xfs_bmap_finish(&args->trans, 1310 error = xfs_bmap_finish(&args->trans,
1309 args->flist, 1311 args->flist,
1310 *args->firstblock,
1311 &committed); 1312 &committed);
1312 } 1313 }
1313 if (error) { 1314 if (error) {
@@ -1347,7 +1348,7 @@ restart:
1347 error = xfs_da_split(state); 1348 error = xfs_da_split(state);
1348 if (!error) { 1349 if (!error) {
1349 error = xfs_bmap_finish(&args->trans, args->flist, 1350 error = xfs_bmap_finish(&args->trans, args->flist,
1350 *args->firstblock, &committed); 1351 &committed);
1351 } 1352 }
1352 if (error) { 1353 if (error) {
1353 ASSERT(committed); 1354 ASSERT(committed);
@@ -1459,7 +1460,6 @@ restart:
1459 if (!error) { 1460 if (!error) {
1460 error = xfs_bmap_finish(&args->trans, 1461 error = xfs_bmap_finish(&args->trans,
1461 args->flist, 1462 args->flist,
1462 *args->firstblock,
1463 &committed); 1463 &committed);
1464 } 1464 }
1465 if (error) { 1465 if (error) {
@@ -1594,7 +1594,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1594 error = xfs_da_join(state); 1594 error = xfs_da_join(state);
1595 if (!error) { 1595 if (!error) {
1596 error = xfs_bmap_finish(&args->trans, args->flist, 1596 error = xfs_bmap_finish(&args->trans, args->flist,
1597 *args->firstblock, &committed); 1597 &committed);
1598 } 1598 }
1599 if (error) { 1599 if (error) {
1600 ASSERT(committed); 1600 ASSERT(committed);
@@ -1646,7 +1646,6 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1646 if (!error) { 1646 if (!error) {
1647 error = xfs_bmap_finish(&args->trans, 1647 error = xfs_bmap_finish(&args->trans,
1648 args->flist, 1648 args->flist,
1649 *args->firstblock,
1650 &committed); 1649 &committed);
1651 } 1650 }
1652 if (error) { 1651 if (error) {
@@ -2090,7 +2089,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2090 args->flist, NULL); 2089 args->flist, NULL);
2091 if (!error) { 2090 if (!error) {
2092 error = xfs_bmap_finish(&args->trans, args->flist, 2091 error = xfs_bmap_finish(&args->trans, args->flist,
2093 *args->firstblock, &committed); 2092 &committed);
2094 } 2093 }
2095 if (error) { 2094 if (error) {
2096 ASSERT(committed); 2095 ASSERT(committed);
@@ -2246,7 +2245,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2246 NULL, &done); 2245 NULL, &done);
2247 if (!error) { 2246 if (!error) {
2248 error = xfs_bmap_finish(&args->trans, args->flist, 2247 error = xfs_bmap_finish(&args->trans, args->flist,
2249 *args->firstblock, &committed); 2248 &committed);
2250 } 2249 }
2251 if (error) { 2250 if (error) {
2252 ASSERT(committed); 2251 ASSERT(committed);
@@ -2477,7 +2476,7 @@ posix_acl_default_exists(
2477 return xfs_acl_vhasacl_default(vp); 2476 return xfs_acl_vhasacl_default(vp);
2478} 2477}
2479 2478
2480STATIC struct attrnames posix_acl_access = { 2479static struct attrnames posix_acl_access = {
2481 .attr_name = "posix_acl_access", 2480 .attr_name = "posix_acl_access",
2482 .attr_namelen = sizeof("posix_acl_access") - 1, 2481 .attr_namelen = sizeof("posix_acl_access") - 1,
2483 .attr_get = posix_acl_access_get, 2482 .attr_get = posix_acl_access_get,
@@ -2486,7 +2485,7 @@ STATIC struct attrnames posix_acl_access = {
2486 .attr_exists = posix_acl_access_exists, 2485 .attr_exists = posix_acl_access_exists,
2487}; 2486};
2488 2487
2489STATIC struct attrnames posix_acl_default = { 2488static struct attrnames posix_acl_default = {
2490 .attr_name = "posix_acl_default", 2489 .attr_name = "posix_acl_default",
2491 .attr_namelen = sizeof("posix_acl_default") - 1, 2490 .attr_namelen = sizeof("posix_acl_default") - 1,
2492 .attr_get = posix_acl_default_get, 2491 .attr_get = posix_acl_default_get,
@@ -2495,7 +2494,7 @@ STATIC struct attrnames posix_acl_default = {
2495 .attr_exists = posix_acl_default_exists, 2494 .attr_exists = posix_acl_default_exists,
2496}; 2495};
2497 2496
2498STATIC struct attrnames *attr_system_names[] = 2497static struct attrnames *attr_system_names[] =
2499 { &posix_acl_access, &posix_acl_default }; 2498 { &posix_acl_access, &posix_acl_default };
2500 2499
2501 2500
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 9719bbef122c..8eab73e8340a 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -94,7 +94,7 @@ STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
94 * Namespace helper routines 94 * Namespace helper routines
95 *========================================================================*/ 95 *========================================================================*/
96 96
97STATIC inline attrnames_t * 97STATIC_INLINE attrnames_t *
98xfs_attr_flags_namesp(int flags) 98xfs_attr_flags_namesp(int flags)
99{ 99{
100 return ((flags & XFS_ATTR_SECURE) ? &attr_secure: 100 return ((flags & XFS_ATTR_SECURE) ? &attr_secure:
@@ -105,7 +105,7 @@ xfs_attr_flags_namesp(int flags)
105 * If namespace bits don't match return 0. 105 * If namespace bits don't match return 0.
106 * If all match then return 1. 106 * If all match then return 1.
107 */ 107 */
108STATIC inline int 108STATIC_INLINE int
109xfs_attr_namesp_match(int arg_flags, int ondisk_flags) 109xfs_attr_namesp_match(int arg_flags, int ondisk_flags)
110{ 110{
111 return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); 111 return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags);
@@ -116,7 +116,7 @@ xfs_attr_namesp_match(int arg_flags, int ondisk_flags)
116 * then return 0. 116 * then return 0.
117 * If all match or are overridable then return 1. 117 * If all match or are overridable then return 1.
118 */ 118 */
119STATIC inline int 119STATIC_INLINE int
120xfs_attr_namesp_match_overrides(int arg_flags, int ondisk_flags) 120xfs_attr_namesp_match_overrides(int arg_flags, int ondisk_flags)
121{ 121{
122 if (((arg_flags & ATTR_SECURE) == 0) != 122 if (((arg_flags & ATTR_SECURE) == 0) !=
@@ -150,6 +150,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
150 int offset; 150 int offset;
151 int minforkoff; /* lower limit on valid forkoff locations */ 151 int minforkoff; /* lower limit on valid forkoff locations */
152 int maxforkoff; /* upper limit on valid forkoff locations */ 152 int maxforkoff; /* upper limit on valid forkoff locations */
153 int dsize;
153 xfs_mount_t *mp = dp->i_mount; 154 xfs_mount_t *mp = dp->i_mount;
154 155
155 offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */ 156 offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */
@@ -169,8 +170,43 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
169 return 0; 170 return 0;
170 } 171 }
171 172
172 /* data fork btree root can have at least this many key/ptr pairs */ 173 dsize = dp->i_df.if_bytes;
173 minforkoff = MAX(dp->i_df.if_bytes, XFS_BMDR_SPACE_CALC(MINDBTPTRS)); 174
175 switch (dp->i_d.di_format) {
176 case XFS_DINODE_FMT_EXTENTS:
177 /*
178 * If there is no attr fork and the data fork is extents,
179 * determine if creating the default attr fork will result
180 * in the extents form migrating to btree. If so, the
181 * minimum offset only needs to be the space required for
182 * the btree root.
183 */
184 if (!dp->i_d.di_forkoff && dp->i_df.if_bytes > mp->m_attroffset)
185 dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
186 break;
187
188 case XFS_DINODE_FMT_BTREE:
189 /*
190 * If have data btree then keep forkoff if we have one,
191 * otherwise we are adding a new attr, so then we set
192 * minforkoff to where the btree root can finish so we have
193 * plenty of room for attrs
194 */
195 if (dp->i_d.di_forkoff) {
196 if (offset < dp->i_d.di_forkoff)
197 return 0;
198 else
199 return dp->i_d.di_forkoff;
200 } else
201 dsize = XFS_BMAP_BROOT_SPACE(dp->i_df.if_broot);
202 break;
203 }
204
205 /*
206 * A data fork btree root must have space for at least
207 * MINDBTPTRS key/ptr pairs if the data fork is small or empty.
208 */
209 minforkoff = MAX(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
174 minforkoff = roundup(minforkoff, 8) >> 3; 210 minforkoff = roundup(minforkoff, 8) >> 3;
175 211
176 /* attr fork btree root can have at least this many key/ptr pairs */ 212 /* attr fork btree root can have at least this many key/ptr pairs */
@@ -336,7 +372,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
336 */ 372 */
337 totsize -= size; 373 totsize -= size;
338 if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname && 374 if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname &&
339 (mp->m_flags & XFS_MOUNT_ATTR2)) { 375 (mp->m_flags & XFS_MOUNT_ATTR2) &&
376 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) {
340 /* 377 /*
341 * Last attribute now removed, revert to original 378 * Last attribute now removed, revert to original
342 * inode format making all literal area available 379 * inode format making all literal area available
@@ -355,7 +392,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
355 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); 392 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
356 ASSERT(dp->i_d.di_forkoff); 393 ASSERT(dp->i_d.di_forkoff);
357 ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname || 394 ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname ||
358 !(mp->m_flags & XFS_MOUNT_ATTR2)); 395 !(mp->m_flags & XFS_MOUNT_ATTR2) ||
396 dp->i_d.di_format == XFS_DINODE_FMT_BTREE);
359 dp->i_afp->if_ext_max = 397 dp->i_afp->if_ext_max =
360 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); 398 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
361 dp->i_df.if_ext_max = 399 dp->i_df.if_ext_max =
@@ -748,6 +786,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
748 + be16_to_cpu(name_loc->valuelen); 786 + be16_to_cpu(name_loc->valuelen);
749 } 787 }
750 if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && 788 if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
789 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
751 (bytes == sizeof(struct xfs_attr_sf_hdr))) 790 (bytes == sizeof(struct xfs_attr_sf_hdr)))
752 return(-1); 791 return(-1);
753 return(xfs_attr_shortform_bytesfit(dp, bytes)); 792 return(xfs_attr_shortform_bytesfit(dp, bytes));
@@ -786,6 +825,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
786 825
787 if (forkoff == -1) { 826 if (forkoff == -1) {
788 ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2); 827 ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
828 ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
789 829
790 /* 830 /*
791 * Last attribute was removed, revert to original 831 * Last attribute was removed, revert to original
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 43be6a7e47c6..1afe07f67e3b 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -29,7 +29,7 @@
29/* 29/*
30 * Index of high bit number in byte, -1 for none set, 0..7 otherwise. 30 * Index of high bit number in byte, -1 for none set, 0..7 otherwise.
31 */ 31 */
32STATIC const char xfs_highbit[256] = { 32static const char xfs_highbit[256] = {
33 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */ 33 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */
34 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */ 34 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */
35 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */ 35 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 498ad50d1f45..87795188cedf 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -185,16 +185,6 @@ xfs_bmap_btree_to_extents(
185 int *logflagsp, /* inode logging flags */ 185 int *logflagsp, /* inode logging flags */
186 int whichfork); /* data or attr fork */ 186 int whichfork); /* data or attr fork */
187 187
188#ifdef DEBUG
189/*
190 * Check that the extents list for the inode ip is in the right order.
191 */
192STATIC void
193xfs_bmap_check_extents(
194 xfs_inode_t *ip, /* incore inode pointer */
195 int whichfork); /* data or attr fork */
196#endif
197
198/* 188/*
199 * Called by xfs_bmapi to update file extent records and the btree 189 * Called by xfs_bmapi to update file extent records and the btree
200 * after removing space (or undoing a delayed allocation). 190 * after removing space (or undoing a delayed allocation).
@@ -410,7 +400,6 @@ xfs_bmap_count_leaves(
410STATIC int 400STATIC int
411xfs_bmap_disk_count_leaves( 401xfs_bmap_disk_count_leaves(
412 xfs_ifork_t *ifp, 402 xfs_ifork_t *ifp,
413 xfs_mount_t *mp,
414 xfs_extnum_t idx, 403 xfs_extnum_t idx,
415 xfs_bmbt_block_t *block, 404 xfs_bmbt_block_t *block,
416 int numrecs, 405 int numrecs,
@@ -684,7 +673,7 @@ xfs_bmap_add_extent(
684 ASSERT(nblks <= da_old); 673 ASSERT(nblks <= da_old);
685 if (nblks < da_old) 674 if (nblks < da_old)
686 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, 675 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
687 (int)(da_old - nblks), rsvd); 676 (int64_t)(da_old - nblks), rsvd);
688 } 677 }
689 /* 678 /*
690 * Clear out the allocated field, done with it now in any case. 679 * Clear out the allocated field, done with it now in any case.
@@ -1209,7 +1198,7 @@ xfs_bmap_add_extent_delay_real(
1209 diff = (int)(temp + temp2 - STARTBLOCKVAL(PREV.br_startblock) - 1198 diff = (int)(temp + temp2 - STARTBLOCKVAL(PREV.br_startblock) -
1210 (cur ? cur->bc_private.b.allocated : 0)); 1199 (cur ? cur->bc_private.b.allocated : 0));
1211 if (diff > 0 && 1200 if (diff > 0 &&
1212 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -diff, rsvd)) { 1201 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd)) {
1213 /* 1202 /*
1214 * Ick gross gag me with a spoon. 1203 * Ick gross gag me with a spoon.
1215 */ 1204 */
@@ -1220,7 +1209,7 @@ xfs_bmap_add_extent_delay_real(
1220 diff--; 1209 diff--;
1221 if (!diff || 1210 if (!diff ||
1222 !xfs_mod_incore_sb(ip->i_mount, 1211 !xfs_mod_incore_sb(ip->i_mount,
1223 XFS_SBS_FDBLOCKS, -diff, rsvd)) 1212 XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
1224 break; 1213 break;
1225 } 1214 }
1226 if (temp2) { 1215 if (temp2) {
@@ -1228,7 +1217,7 @@ xfs_bmap_add_extent_delay_real(
1228 diff--; 1217 diff--;
1229 if (!diff || 1218 if (!diff ||
1230 !xfs_mod_incore_sb(ip->i_mount, 1219 !xfs_mod_incore_sb(ip->i_mount,
1231 XFS_SBS_FDBLOCKS, -diff, rsvd)) 1220 XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
1232 break; 1221 break;
1233 } 1222 }
1234 } 1223 }
@@ -2015,7 +2004,7 @@ xfs_bmap_add_extent_hole_delay(
2015 if (oldlen != newlen) { 2004 if (oldlen != newlen) {
2016 ASSERT(oldlen > newlen); 2005 ASSERT(oldlen > newlen);
2017 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, 2006 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
2018 (int)(oldlen - newlen), rsvd); 2007 (int64_t)(oldlen - newlen), rsvd);
2019 /* 2008 /*
2020 * Nothing to do for disk quota accounting here. 2009 * Nothing to do for disk quota accounting here.
2021 */ 2010 */
@@ -3359,7 +3348,7 @@ xfs_bmap_del_extent(
3359 */ 3348 */
3360 ASSERT(da_old >= da_new); 3349 ASSERT(da_old >= da_new);
3361 if (da_old > da_new) 3350 if (da_old > da_new)
3362 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int)(da_old - da_new), 3351 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int64_t)(da_old - da_new),
3363 rsvd); 3352 rsvd);
3364 if (delta) { 3353 if (delta) {
3365 /* DELTA: report the original extent. */ 3354 /* DELTA: report the original extent. */
@@ -3543,6 +3532,7 @@ xfs_bmap_forkoff_reset(
3543 if (whichfork == XFS_ATTR_FORK && 3532 if (whichfork == XFS_ATTR_FORK &&
3544 (ip->i_d.di_format != XFS_DINODE_FMT_DEV) && 3533 (ip->i_d.di_format != XFS_DINODE_FMT_DEV) &&
3545 (ip->i_d.di_format != XFS_DINODE_FMT_UUID) && 3534 (ip->i_d.di_format != XFS_DINODE_FMT_UUID) &&
3535 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
3546 ((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) { 3536 ((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) {
3547 ip->i_d.di_forkoff = mp->m_attroffset >> 3; 3537 ip->i_d.di_forkoff = mp->m_attroffset >> 3;
3548 ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) / 3538 ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) /
@@ -4079,7 +4069,7 @@ xfs_bmap_add_attrfork(
4079 } else 4069 } else
4080 XFS_SB_UNLOCK(mp, s); 4070 XFS_SB_UNLOCK(mp, s);
4081 } 4071 }
4082 if ((error = xfs_bmap_finish(&tp, &flist, firstblock, &committed))) 4072 if ((error = xfs_bmap_finish(&tp, &flist, &committed)))
4083 goto error2; 4073 goto error2;
4084 error = xfs_trans_commit(tp, XFS_TRANS_PERM_LOG_RES, NULL); 4074 error = xfs_trans_commit(tp, XFS_TRANS_PERM_LOG_RES, NULL);
4085 ASSERT(ip->i_df.if_ext_max == 4075 ASSERT(ip->i_df.if_ext_max ==
@@ -4212,7 +4202,6 @@ int /* error */
4212xfs_bmap_finish( 4202xfs_bmap_finish(
4213 xfs_trans_t **tp, /* transaction pointer addr */ 4203 xfs_trans_t **tp, /* transaction pointer addr */
4214 xfs_bmap_free_t *flist, /* i/o: list extents to free */ 4204 xfs_bmap_free_t *flist, /* i/o: list extents to free */
4215 xfs_fsblock_t firstblock, /* controlled ag for allocs */
4216 int *committed) /* xact committed or not */ 4205 int *committed) /* xact committed or not */
4217{ 4206{
4218 xfs_efd_log_item_t *efd; /* extent free data */ 4207 xfs_efd_log_item_t *efd; /* extent free data */
@@ -4533,8 +4522,7 @@ xfs_bmap_read_extents(
4533 error0); 4522 error0);
4534 if (level == 0) 4523 if (level == 0)
4535 break; 4524 break;
4536 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 4525 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
4537 1, mp->m_bmap_dmxr[1]);
4538 bno = be64_to_cpu(*pp); 4526 bno = be64_to_cpu(*pp);
4539 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); 4527 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
4540 xfs_trans_brelse(tp, bp); 4528 xfs_trans_brelse(tp, bp);
@@ -4577,8 +4565,7 @@ xfs_bmap_read_extents(
4577 /* 4565 /*
4578 * Copy records into the extent records. 4566 * Copy records into the extent records.
4579 */ 4567 */
4580 frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, 4568 frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
4581 block, 1, mp->m_bmap_dmxr[0]);
4582 start = i; 4569 start = i;
4583 for (j = 0; j < num_recs; j++, i++, frp++) { 4570 for (j = 0; j < num_recs; j++, i++, frp++) {
4584 trp = xfs_iext_get_ext(ifp, i); 4571 trp = xfs_iext_get_ext(ifp, i);
@@ -4929,28 +4916,28 @@ xfs_bmapi(
4929 if (rt) { 4916 if (rt) {
4930 error = xfs_mod_incore_sb(mp, 4917 error = xfs_mod_incore_sb(mp,
4931 XFS_SBS_FREXTENTS, 4918 XFS_SBS_FREXTENTS,
4932 -(extsz), (flags & 4919 -((int64_t)extsz), (flags &
4933 XFS_BMAPI_RSVBLOCKS)); 4920 XFS_BMAPI_RSVBLOCKS));
4934 } else { 4921 } else {
4935 error = xfs_mod_incore_sb(mp, 4922 error = xfs_mod_incore_sb(mp,
4936 XFS_SBS_FDBLOCKS, 4923 XFS_SBS_FDBLOCKS,
4937 -(alen), (flags & 4924 -((int64_t)alen), (flags &
4938 XFS_BMAPI_RSVBLOCKS)); 4925 XFS_BMAPI_RSVBLOCKS));
4939 } 4926 }
4940 if (!error) { 4927 if (!error) {
4941 error = xfs_mod_incore_sb(mp, 4928 error = xfs_mod_incore_sb(mp,
4942 XFS_SBS_FDBLOCKS, 4929 XFS_SBS_FDBLOCKS,
4943 -(indlen), (flags & 4930 -((int64_t)indlen), (flags &
4944 XFS_BMAPI_RSVBLOCKS)); 4931 XFS_BMAPI_RSVBLOCKS));
4945 if (error && rt) 4932 if (error && rt)
4946 xfs_mod_incore_sb(mp, 4933 xfs_mod_incore_sb(mp,
4947 XFS_SBS_FREXTENTS, 4934 XFS_SBS_FREXTENTS,
4948 extsz, (flags & 4935 (int64_t)extsz, (flags &
4949 XFS_BMAPI_RSVBLOCKS)); 4936 XFS_BMAPI_RSVBLOCKS));
4950 else if (error) 4937 else if (error)
4951 xfs_mod_incore_sb(mp, 4938 xfs_mod_incore_sb(mp,
4952 XFS_SBS_FDBLOCKS, 4939 XFS_SBS_FDBLOCKS,
4953 alen, (flags & 4940 (int64_t)alen, (flags &
4954 XFS_BMAPI_RSVBLOCKS)); 4941 XFS_BMAPI_RSVBLOCKS));
4955 } 4942 }
4956 4943
@@ -5616,13 +5603,13 @@ xfs_bunmapi(
5616 rtexts = XFS_FSB_TO_B(mp, del.br_blockcount); 5603 rtexts = XFS_FSB_TO_B(mp, del.br_blockcount);
5617 do_div(rtexts, mp->m_sb.sb_rextsize); 5604 do_div(rtexts, mp->m_sb.sb_rextsize);
5618 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, 5605 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS,
5619 (int)rtexts, rsvd); 5606 (int64_t)rtexts, rsvd);
5620 (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5607 (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,
5621 NULL, ip, -((long)del.br_blockcount), 0, 5608 NULL, ip, -((long)del.br_blockcount), 0,
5622 XFS_QMOPT_RES_RTBLKS); 5609 XFS_QMOPT_RES_RTBLKS);
5623 } else { 5610 } else {
5624 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 5611 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS,
5625 (int)del.br_blockcount, rsvd); 5612 (int64_t)del.br_blockcount, rsvd);
5626 (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5613 (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,
5627 NULL, ip, -((long)del.br_blockcount), 0, 5614 NULL, ip, -((long)del.br_blockcount), 0,
5628 XFS_QMOPT_RES_REGBLKS); 5615 XFS_QMOPT_RES_REGBLKS);
@@ -6048,32 +6035,6 @@ xfs_bmap_eof(
6048} 6035}
6049 6036
6050#ifdef DEBUG 6037#ifdef DEBUG
6051/*
6052 * Check that the extents list for the inode ip is in the right order.
6053 */
6054STATIC void
6055xfs_bmap_check_extents(
6056 xfs_inode_t *ip, /* incore inode pointer */
6057 int whichfork) /* data or attr fork */
6058{
6059 xfs_bmbt_rec_t *ep; /* current extent entry */
6060 xfs_extnum_t idx; /* extent record index */
6061 xfs_ifork_t *ifp; /* inode fork pointer */
6062 xfs_extnum_t nextents; /* number of extents in list */
6063 xfs_bmbt_rec_t *nextp; /* next extent entry */
6064
6065 ifp = XFS_IFORK_PTR(ip, whichfork);
6066 ASSERT(ifp->if_flags & XFS_IFEXTENTS);
6067 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
6068 ep = xfs_iext_get_ext(ifp, 0);
6069 for (idx = 0; idx < nextents - 1; idx++) {
6070 nextp = xfs_iext_get_ext(ifp, idx + 1);
6071 xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep,
6072 (void *)(nextp));
6073 ep = nextp;
6074 }
6075}
6076
6077STATIC 6038STATIC
6078xfs_buf_t * 6039xfs_buf_t *
6079xfs_bmap_get_bp( 6040xfs_bmap_get_bp(
@@ -6156,8 +6117,7 @@ xfs_check_block(
6156 if (root) { 6117 if (root) {
6157 keyp = XFS_BMAP_BROOT_KEY_ADDR(block, i, sz); 6118 keyp = XFS_BMAP_BROOT_KEY_ADDR(block, i, sz);
6158 } else { 6119 } else {
6159 keyp = XFS_BTREE_KEY_ADDR(mp->m_sb.sb_blocksize, 6120 keyp = XFS_BTREE_KEY_ADDR(xfs_bmbt, block, i);
6160 xfs_bmbt, block, i, dmxr);
6161 } 6121 }
6162 6122
6163 if (prevp) { 6123 if (prevp) {
@@ -6172,15 +6132,14 @@ xfs_check_block(
6172 if (root) { 6132 if (root) {
6173 pp = XFS_BMAP_BROOT_PTR_ADDR(block, i, sz); 6133 pp = XFS_BMAP_BROOT_PTR_ADDR(block, i, sz);
6174 } else { 6134 } else {
6175 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 6135 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr);
6176 xfs_bmbt, block, i, dmxr);
6177 } 6136 }
6178 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { 6137 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
6179 if (root) { 6138 if (root) {
6180 thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); 6139 thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz);
6181 } else { 6140 } else {
6182 thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 6141 thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j,
6183 xfs_bmbt, block, j, dmxr); 6142 dmxr);
6184 } 6143 }
6185 if (*thispa == *pp) { 6144 if (*thispa == *pp) {
6186 cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", 6145 cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld",
@@ -6267,8 +6226,7 @@ xfs_bmap_check_leaf_extents(
6267 */ 6226 */
6268 6227
6269 xfs_check_block(block, mp, 0, 0); 6228 xfs_check_block(block, mp, 0, 0);
6270 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 6229 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
6271 1, mp->m_bmap_dmxr[1]);
6272 bno = be64_to_cpu(*pp); 6230 bno = be64_to_cpu(*pp);
6273 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); 6231 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
6274 if (bp_release) { 6232 if (bp_release) {
@@ -6305,11 +6263,9 @@ xfs_bmap_check_leaf_extents(
6305 * conform with the first entry in this one. 6263 * conform with the first entry in this one.
6306 */ 6264 */
6307 6265
6308 ep = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, 6266 ep = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
6309 block, 1, mp->m_bmap_dmxr[0]);
6310 for (j = 1; j < num_recs; j++) { 6267 for (j = 1; j < num_recs; j++) {
6311 nextp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, 6268 nextp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, j + 1);
6312 block, j + 1, mp->m_bmap_dmxr[0]);
6313 if (lastp) { 6269 if (lastp) {
6314 xfs_btree_check_rec(XFS_BTNUM_BMAP, 6270 xfs_btree_check_rec(XFS_BTNUM_BMAP,
6315 (void *)lastp, (void *)ep); 6271 (void *)lastp, (void *)ep);
@@ -6454,8 +6410,7 @@ xfs_bmap_count_tree(
6454 } 6410 }
6455 6411
6456 /* Dive to the next level */ 6412 /* Dive to the next level */
6457 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 6413 pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
6458 xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
6459 bno = be64_to_cpu(*pp); 6414 bno = be64_to_cpu(*pp);
6460 if (unlikely((error = 6415 if (unlikely((error =
6461 xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { 6416 xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) {
@@ -6470,7 +6425,7 @@ xfs_bmap_count_tree(
6470 for (;;) { 6425 for (;;) {
6471 nextbno = be64_to_cpu(block->bb_rightsib); 6426 nextbno = be64_to_cpu(block->bb_rightsib);
6472 numrecs = be16_to_cpu(block->bb_numrecs); 6427 numrecs = be16_to_cpu(block->bb_numrecs);
6473 if (unlikely(xfs_bmap_disk_count_leaves(ifp, mp, 6428 if (unlikely(xfs_bmap_disk_count_leaves(ifp,
6474 0, block, numrecs, count) < 0)) { 6429 0, block, numrecs, count) < 0)) {
6475 xfs_trans_brelse(tp, bp); 6430 xfs_trans_brelse(tp, bp);
6476 XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", 6431 XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
@@ -6518,7 +6473,6 @@ xfs_bmap_count_leaves(
6518int 6473int
6519xfs_bmap_disk_count_leaves( 6474xfs_bmap_disk_count_leaves(
6520 xfs_ifork_t *ifp, 6475 xfs_ifork_t *ifp,
6521 xfs_mount_t *mp,
6522 xfs_extnum_t idx, 6476 xfs_extnum_t idx,
6523 xfs_bmbt_block_t *block, 6477 xfs_bmbt_block_t *block,
6524 int numrecs, 6478 int numrecs,
@@ -6528,8 +6482,7 @@ xfs_bmap_disk_count_leaves(
6528 xfs_bmbt_rec_t *frp; 6482 xfs_bmbt_rec_t *frp;
6529 6483
6530 for (b = 1; b <= numrecs; b++) { 6484 for (b = 1; b <= numrecs; b++) {
6531 frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, 6485 frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b);
6532 xfs_bmbt, block, idx + b, mp->m_bmap_dmxr[0]);
6533 *count += xfs_bmbt_disk_get_blockcount(frp); 6486 *count += xfs_bmbt_disk_get_blockcount(frp);
6534 } 6487 }
6535 return 0; 6488 return 0;
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 80e93409b78d..4f24c7e39b31 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -202,7 +202,6 @@ int /* error */
202xfs_bmap_finish( 202xfs_bmap_finish(
203 struct xfs_trans **tp, /* transaction pointer addr */ 203 struct xfs_trans **tp, /* transaction pointer addr */
204 xfs_bmap_free_t *flist, /* i/o: list extents to free */ 204 xfs_bmap_free_t *flist, /* i/o: list extents to free */
205 xfs_fsblock_t firstblock, /* controlled a.g. for allocs */
206 int *committed); /* xact committed or not */ 205 int *committed); /* xact committed or not */
207 206
208/* 207/*
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index a7b835bf870a..0bf192fea3eb 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -678,47 +678,6 @@ error0:
678 return error; 678 return error;
679} 679}
680 680
681#ifdef DEBUG
682/*
683 * Get the data from the pointed-to record.
684 */
685int
686xfs_bmbt_get_rec(
687 xfs_btree_cur_t *cur,
688 xfs_fileoff_t *off,
689 xfs_fsblock_t *bno,
690 xfs_filblks_t *len,
691 xfs_exntst_t *state,
692 int *stat)
693{
694 xfs_bmbt_block_t *block;
695 xfs_buf_t *bp;
696#ifdef DEBUG
697 int error;
698#endif
699 int ptr;
700 xfs_bmbt_rec_t *rp;
701
702 block = xfs_bmbt_get_block(cur, 0, &bp);
703 ptr = cur->bc_ptrs[0];
704#ifdef DEBUG
705 if ((error = xfs_btree_check_lblock(cur, block, 0, bp)))
706 return error;
707#endif
708 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
709 *stat = 0;
710 return 0;
711 }
712 rp = XFS_BMAP_REC_IADDR(block, ptr, cur);
713 *off = xfs_bmbt_disk_get_startoff(rp);
714 *bno = xfs_bmbt_disk_get_startblock(rp);
715 *len = xfs_bmbt_disk_get_blockcount(rp);
716 *state = xfs_bmbt_disk_get_state(rp);
717 *stat = 1;
718 return 0;
719}
720#endif
721
722/* 681/*
723 * Insert one record/level. Return information to the caller 682 * Insert one record/level. Return information to the caller
724 * allowing the next level up to proceed if necessary. 683 * allowing the next level up to proceed if necessary.
@@ -1731,9 +1690,9 @@ xfs_bmdr_to_bmbt(
1731 rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); 1690 rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
1732 rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); 1691 rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
1733 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); 1692 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
1734 fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 1693 fkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1);
1735 tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); 1694 tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
1736 fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 1695 fpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr);
1737 tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); 1696 tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
1738 dmxr = be16_to_cpu(dblock->bb_numrecs); 1697 dmxr = be16_to_cpu(dblock->bb_numrecs);
1739 memcpy(tkp, fkp, sizeof(*fkp) * dmxr); 1698 memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
@@ -1862,7 +1821,7 @@ xfs_bmbt_delete(
1862 * xfs_bmbt_get_startblock, xfs_bmbt_get_blockcount and xfs_bmbt_get_state. 1821 * xfs_bmbt_get_startblock, xfs_bmbt_get_blockcount and xfs_bmbt_get_state.
1863 */ 1822 */
1864 1823
1865STATIC __inline__ void 1824STATIC_INLINE void
1866__xfs_bmbt_get_all( 1825__xfs_bmbt_get_all(
1867 __uint64_t l0, 1826 __uint64_t l0,
1868 __uint64_t l1, 1827 __uint64_t l1,
@@ -2016,30 +1975,6 @@ xfs_bmbt_disk_get_blockcount(
2016} 1975}
2017 1976
2018/* 1977/*
2019 * Extract the startblock field from an on disk bmap extent record.
2020 */
2021xfs_fsblock_t
2022xfs_bmbt_disk_get_startblock(
2023 xfs_bmbt_rec_t *r)
2024{
2025#if XFS_BIG_BLKNOS
2026 return (((xfs_fsblock_t)INT_GET(r->l0, ARCH_CONVERT) & XFS_MASK64LO(9)) << 43) |
2027 (((xfs_fsblock_t)INT_GET(r->l1, ARCH_CONVERT)) >> 21);
2028#else
2029#ifdef DEBUG
2030 xfs_dfsbno_t b;
2031
2032 b = (((xfs_dfsbno_t)INT_GET(r->l0, ARCH_CONVERT) & XFS_MASK64LO(9)) << 43) |
2033 (((xfs_dfsbno_t)INT_GET(r->l1, ARCH_CONVERT)) >> 21);
2034 ASSERT((b >> 32) == 0 || ISNULLDSTARTBLOCK(b));
2035 return (xfs_fsblock_t)b;
2036#else /* !DEBUG */
2037 return (xfs_fsblock_t)(((xfs_dfsbno_t)INT_GET(r->l1, ARCH_CONVERT)) >> 21);
2038#endif /* DEBUG */
2039#endif /* XFS_BIG_BLKNOS */
2040}
2041
2042/*
2043 * Extract the startoff field from a disk format bmap extent record. 1978 * Extract the startoff field from a disk format bmap extent record.
2044 */ 1979 */
2045xfs_fileoff_t 1980xfs_fileoff_t
@@ -2049,17 +1984,6 @@ xfs_bmbt_disk_get_startoff(
2049 return ((xfs_fileoff_t)INT_GET(r->l0, ARCH_CONVERT) & 1984 return ((xfs_fileoff_t)INT_GET(r->l0, ARCH_CONVERT) &
2050 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 1985 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
2051} 1986}
2052
2053xfs_exntst_t
2054xfs_bmbt_disk_get_state(
2055 xfs_bmbt_rec_t *r)
2056{
2057 int ext_flag;
2058
2059 ext_flag = (int)((INT_GET(r->l0, ARCH_CONVERT)) >> (64 - BMBT_EXNTFLAG_BITLEN));
2060 return xfs_extent_state(xfs_bmbt_disk_get_blockcount(r),
2061 ext_flag);
2062}
2063#endif /* XFS_NATIVE_HOST */ 1987#endif /* XFS_NATIVE_HOST */
2064 1988
2065 1989
@@ -2684,9 +2608,9 @@ xfs_bmbt_to_bmdr(
2684 dblock->bb_numrecs = rblock->bb_numrecs; 2608 dblock->bb_numrecs = rblock->bb_numrecs;
2685 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); 2609 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
2686 fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); 2610 fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
2687 tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 2611 tkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1);
2688 fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); 2612 fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
2689 tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 2613 tpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr);
2690 dmxr = be16_to_cpu(dblock->bb_numrecs); 2614 dmxr = be16_to_cpu(dblock->bb_numrecs);
2691 memcpy(tkp, fkp, sizeof(*fkp) * dmxr); 2615 memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
2692 memcpy(tpp, fpp, sizeof(*fpp) * dmxr); 2616 memcpy(tpp, fpp, sizeof(*fpp) * dmxr);
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 49539de9525b..a77b1b753d0c 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -175,19 +175,11 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
175 175
176#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) 176#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
177 177
178#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
179#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize) 178#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
180#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \ 179#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
181 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ 180 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
182 (cur)->bc_private.b.whichfork)->if_broot_bytes) 181 (cur)->bc_private.b.whichfork)->if_broot_bytes)
183 182
184#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \
185 (((lev) == (cur)->bc_nlevels - 1 ? \
186 XFS_BMAP_RBLOCK_DSIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
187#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
188 (((lev) == (cur)->bc_nlevels - 1 ? \
189 XFS_BMAP_RBLOCK_ISIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
190
191#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ 183#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \
192 (((lev) == (cur)->bc_nlevels - 1 ? \ 184 (((lev) == (cur)->bc_nlevels - 1 ? \
193 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ 185 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \
@@ -210,37 +202,21 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
210 xfs_bmbt, (lev) == 0) : \ 202 xfs_bmbt, (lev) == 0) : \
211 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0]))) 203 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
212 204
213#define XFS_BMAP_REC_DADDR(bb,i,cur) \ 205#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
214 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 206
215 be16_to_cpu((bb)->bb_level), cur), \ 207#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
216 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
217 be16_to_cpu((bb)->bb_level), cur)))
218#define XFS_BMAP_REC_IADDR(bb,i,cur) \
219 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
220 be16_to_cpu((bb)->bb_level), cur), \
221 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
222 be16_to_cpu((bb)->bb_level), cur)))
223 208
224#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ 209#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
225 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 210 (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))
226 be16_to_cpu((bb)->bb_level), cur), \ 211
227 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
228 be16_to_cpu((bb)->bb_level), cur)))
229#define XFS_BMAP_KEY_IADDR(bb,i,cur) \ 212#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
230 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 213 (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))
231 be16_to_cpu((bb)->bb_level), cur), \
232 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
233 be16_to_cpu((bb)->bb_level), cur)))
234 214
235#define XFS_BMAP_PTR_DADDR(bb,i,cur) \ 215#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
236 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 216 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
237 be16_to_cpu((bb)->bb_level), cur), \
238 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
239 be16_to_cpu((bb)->bb_level), cur))) 217 be16_to_cpu((bb)->bb_level), cur)))
240#define XFS_BMAP_PTR_IADDR(bb,i,cur) \ 218#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
241 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 219 (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
242 be16_to_cpu((bb)->bb_level), cur), \
243 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
244 be16_to_cpu((bb)->bb_level), cur))) 220 be16_to_cpu((bb)->bb_level), cur)))
245 221
246/* 222/*
@@ -248,11 +224,11 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
248 * we don't have a cursor. 224 * we don't have a cursor.
249 */ 225 */
250#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ 226#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \
251 (XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) 227 (XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i))
252#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ 228#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
253 (XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) 229 (XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i))
254#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ 230#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \
255 (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) 231 (XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
256 232
257#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs) 233#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs)
258#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0) 234#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
@@ -315,15 +291,11 @@ extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r);
315 291
316#ifndef XFS_NATIVE_HOST 292#ifndef XFS_NATIVE_HOST
317extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); 293extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
318extern xfs_exntst_t xfs_bmbt_disk_get_state(xfs_bmbt_rec_t *r);
319extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r); 294extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r);
320extern xfs_fsblock_t xfs_bmbt_disk_get_startblock(xfs_bmbt_rec_t *r);
321extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r); 295extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r);
322#else 296#else
323#define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s) 297#define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s)
324#define xfs_bmbt_disk_get_state(r) xfs_bmbt_get_state(r)
325#define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r) 298#define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r)
326#define xfs_bmbt_disk_get_startblock(r) xfs_bmbt_get_blockcount(r)
327#define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r) 299#define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r)
328#endif /* XFS_NATIVE_HOST */ 300#endif /* XFS_NATIVE_HOST */
329 301
@@ -364,15 +336,6 @@ extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
364extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t, 336extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t,
365 xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t); 337 xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t);
366 338
367#ifdef DEBUG
368/*
369 * Get the data from the pointed-to record.
370 */
371extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *,
372 xfs_fsblock_t *, xfs_filblks_t *,
373 xfs_exntst_t *, int *);
374#endif
375
376#endif /* __KERNEL__ */ 339#endif /* __KERNEL__ */
377 340
378#endif /* __XFS_BMAP_BTREE_H__ */ 341#endif /* __XFS_BMAP_BTREE_H__ */
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 892b06c54263..4e27d55a1e73 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -122,13 +122,13 @@ extern const __uint32_t xfs_magics[];
122 * Given block size, type prefix, block pointer, and index of requested entry 122 * Given block size, type prefix, block pointer, and index of requested entry
123 * (first entry numbered 1). 123 * (first entry numbered 1).
124 */ 124 */
125#define XFS_BTREE_REC_ADDR(bsz,t,bb,i,mxr) \ 125#define XFS_BTREE_REC_ADDR(t,bb,i) \
126 ((t ## _rec_t *)((char *)(bb) + sizeof(t ## _block_t) + \ 126 ((t ## _rec_t *)((char *)(bb) + sizeof(t ## _block_t) + \
127 ((i) - 1) * sizeof(t ## _rec_t))) 127 ((i) - 1) * sizeof(t ## _rec_t)))
128#define XFS_BTREE_KEY_ADDR(bsz,t,bb,i,mxr) \ 128#define XFS_BTREE_KEY_ADDR(t,bb,i) \
129 ((t ## _key_t *)((char *)(bb) + sizeof(t ## _block_t) + \ 129 ((t ## _key_t *)((char *)(bb) + sizeof(t ## _block_t) + \
130 ((i) - 1) * sizeof(t ## _key_t))) 130 ((i) - 1) * sizeof(t ## _key_t)))
131#define XFS_BTREE_PTR_ADDR(bsz,t,bb,i,mxr) \ 131#define XFS_BTREE_PTR_ADDR(t,bb,i,mxr) \
132 ((t ## _ptr_t *)((char *)(bb) + sizeof(t ## _block_t) + \ 132 ((t ## _ptr_t *)((char *)(bb) + sizeof(t ## _block_t) + \
133 (mxr) * sizeof(t ## _key_t) + ((i) - 1) * sizeof(t ## _ptr_t))) 133 (mxr) * sizeof(t ## _key_t) + ((i) - 1) * sizeof(t ## _ptr_t)))
134 134
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 7a55c248ea70..6c1bddc04e31 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -660,7 +660,7 @@ xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
660/* 660/*
661 * This is the ops vector shared by all buf log items. 661 * This is the ops vector shared by all buf log items.
662 */ 662 */
663STATIC struct xfs_item_ops xfs_buf_item_ops = { 663static struct xfs_item_ops xfs_buf_item_ops = {
664 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size, 664 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size,
665 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 665 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
666 xfs_buf_item_format, 666 xfs_buf_item_format,
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 07c708c2b529..d7e136143066 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -21,23 +21,7 @@
21/* 21/*
22 * This is the structure used to lay out a buf log item in the 22 * This is the structure used to lay out a buf log item in the
23 * log. The data map describes which 128 byte chunks of the buffer 23 * log. The data map describes which 128 byte chunks of the buffer
24 * have been logged. This structure works only on buffers that 24 * have been logged.
25 * reside up to the first TB in the filesystem. These buffers are
26 * generated only by pre-6.2 systems and are known as XFS_LI_6_1_BUF.
27 */
28typedef struct xfs_buf_log_format_v1 {
29 unsigned short blf_type; /* buf log item type indicator */
30 unsigned short blf_size; /* size of this item */
31 __int32_t blf_blkno; /* starting blkno of this buf */
32 ushort blf_flags; /* misc state */
33 ushort blf_len; /* number of blocks in this buf */
34 unsigned int blf_map_size; /* size of data bitmap in words */
35 unsigned int blf_data_map[1];/* variable size bitmap of */
36 /* regions of buffer in this item */
37} xfs_buf_log_format_v1_t;
38
39/*
40 * This is a form of the above structure with a 64 bit blkno field.
41 * For 6.2 and beyond, this is XFS_LI_BUF. We use this to log everything. 25 * For 6.2 and beyond, this is XFS_LI_BUF. We use this to log everything.
42 */ 26 */
43typedef struct xfs_buf_log_format_t { 27typedef struct xfs_buf_log_format_t {
diff --git a/fs/xfs/xfs_cap.h b/fs/xfs/xfs_cap.h
deleted file mode 100644
index 7a0e482dd436..000000000000
--- a/fs/xfs/xfs_cap.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_CAP_H__
19#define __XFS_CAP_H__
20
21/*
22 * Capabilities
23 */
24typedef __uint64_t xfs_cap_value_t;
25
26typedef struct xfs_cap_set {
27 xfs_cap_value_t cap_effective; /* use in capability checks */
28 xfs_cap_value_t cap_permitted; /* combined with file attrs */
29 xfs_cap_value_t cap_inheritable;/* pass through exec */
30} xfs_cap_set_t;
31
32/* On-disk XFS extended attribute names */
33#define SGI_CAP_FILE "SGI_CAP_FILE"
34#define SGI_CAP_FILE_SIZE (sizeof(SGI_CAP_FILE)-1)
35#define SGI_CAP_LINUX "SGI_CAP_LINUX"
36#define SGI_CAP_LINUX_SIZE (sizeof(SGI_CAP_LINUX)-1)
37
38/*
39 * For Linux, we take the bitfields directly from capability.h
40 * and no longer attempt to keep this attribute ondisk compatible
41 * with IRIX. Since this attribute is only set on executables,
42 * it just doesn't make much sense to try. We do use a different
43 * named attribute though, to avoid confusion.
44 */
45
46#ifdef __KERNEL__
47
48#ifdef CONFIG_FS_POSIX_CAP
49
50#include <linux/posix_cap_xattr.h>
51
52struct bhv_vnode;
53
54extern int xfs_cap_vhascap(struct bhv_vnode *);
55extern int xfs_cap_vset(struct bhv_vnode *, void *, size_t);
56extern int xfs_cap_vget(struct bhv_vnode *, void *, size_t);
57extern int xfs_cap_vremove(struct bhv_vnode *);
58
59#define _CAP_EXISTS xfs_cap_vhascap
60
61#else
62#define xfs_cap_vset(v,p,sz) (-EOPNOTSUPP)
63#define xfs_cap_vget(v,p,sz) (-EOPNOTSUPP)
64#define xfs_cap_vremove(v) (-EOPNOTSUPP)
65#define _CAP_EXISTS (NULL)
66#endif
67
68#endif /* __KERNEL__ */
69
70#endif /* __XFS_CAP_H__ */
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index a68bc1f1a313..aea37df4aa62 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -1090,8 +1090,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1090 if (blk->magic == XFS_DA_NODE_MAGIC) { 1090 if (blk->magic == XFS_DA_NODE_MAGIC) {
1091 node = blk->bp->data; 1091 node = blk->bp->data;
1092 max = be16_to_cpu(node->hdr.count); 1092 max = be16_to_cpu(node->hdr.count);
1093 btreehashval = node->btree[max-1].hashval; 1093 blk->hashval = be32_to_cpu(node->btree[max-1].hashval);
1094 blk->hashval = be32_to_cpu(btreehashval);
1095 1094
1096 /* 1095 /*
1097 * Binary search. (note: small blocks will skip loop) 1096 * Binary search. (note: small blocks will skip loop)
@@ -2166,21 +2165,6 @@ xfs_da_reada_buf(
2166 return rval; 2165 return rval;
2167} 2166}
2168 2167
2169/*
2170 * Calculate the number of bits needed to hold i different values.
2171 */
2172uint
2173xfs_da_log2_roundup(uint i)
2174{
2175 uint rval;
2176
2177 for (rval = 0; rval < NBBY * sizeof(i); rval++) {
2178 if ((1 << rval) >= i)
2179 break;
2180 }
2181 return(rval);
2182}
2183
2184kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */ 2168kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
2185kmem_zone_t *xfs_dabuf_zone; /* dabuf zone */ 2169kmem_zone_t *xfs_dabuf_zone; /* dabuf zone */
2186 2170
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 4ab865ec8b82..44dabf02f2a3 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -249,7 +249,6 @@ int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
249 xfs_dabuf_t *dead_buf); 249 xfs_dabuf_t *dead_buf);
250 250
251uint xfs_da_hashname(const uchar_t *name_string, int name_length); 251uint xfs_da_hashname(const uchar_t *name_string, int name_length);
252uint xfs_da_log2_roundup(uint i);
253xfs_da_state_t *xfs_da_state_alloc(void); 252xfs_da_state_t *xfs_da_state_alloc(void);
254void xfs_da_state_free(xfs_da_state_t *state); 253void xfs_da_state_free(xfs_da_state_t *state);
255 254
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 50d0faea371d..b847e6a7a3f0 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -41,7 +41,6 @@
41#include "xfs_itable.h" 41#include "xfs_itable.h"
42#include "xfs_dfrag.h" 42#include "xfs_dfrag.h"
43#include "xfs_error.h" 43#include "xfs_error.h"
44#include "xfs_mac.h"
45#include "xfs_rw.h" 44#include "xfs_rw.h"
46 45
47/* 46/*
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index b95681b03d81..b1af54464f00 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -132,32 +132,6 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp)
132} 132}
133 133
134int 134int
135xfs_errortag_clear(int error_tag, xfs_mount_t *mp)
136{
137 int i;
138 int64_t fsid;
139
140 memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
141
142 for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
143 if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
144 xfs_etest[i] = 0;
145 xfs_etest_fsid[i] = 0LL;
146 kmem_free(xfs_etest_fsname[i],
147 strlen(xfs_etest_fsname[i]) + 1);
148 xfs_etest_fsname[i] = NULL;
149 cmn_err(CE_WARN, "Cleared XFS error tag #%d",
150 error_tag);
151 return 0;
152 }
153 }
154
155 cmn_err(CE_WARN, "XFS error tag %d not on", error_tag);
156
157 return 1;
158}
159
160int
161xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud) 135xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud)
162{ 136{
163 int i; 137 int i;
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 0893e16b7d83..5599ada456a1 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -144,7 +144,6 @@ extern void xfs_error_test_init(void);
144#endif /* __ANSI_CPP__ */ 144#endif /* __ANSI_CPP__ */
145 145
146extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp); 146extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp);
147extern int xfs_errortag_clear(int error_tag, xfs_mount_t *mp);
148extern int xfs_errortag_clearall(xfs_mount_t *mp); 147extern int xfs_errortag_clearall(xfs_mount_t *mp);
149extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud); 148extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud);
150#else 149#else
@@ -180,6 +179,6 @@ extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
180 xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args) 179 xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args)
181 180
182#define xfs_fs_mount_cmn_err(f, fmt, args...) \ 181#define xfs_fs_mount_cmn_err(f, fmt, args...) \
183 ((f & XFS_MFSI_QUIET)? cmn_err(CE_WARN, "XFS: " fmt, ## args) : (void)0) 182 ((f & XFS_MFSI_QUIET)? (void)0 : cmn_err(CE_WARN, "XFS: " fmt, ## args))
184 183
185#endif /* __XFS_ERROR_H__ */ 184#endif /* __XFS_ERROR_H__ */
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6dba78199faf..3b14427ee123 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -227,7 +227,7 @@ xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
227/* 227/*
228 * This is the ops vector shared by all efi log items. 228 * This is the ops vector shared by all efi log items.
229 */ 229 */
230STATIC struct xfs_item_ops xfs_efi_item_ops = { 230static struct xfs_item_ops xfs_efi_item_ops = {
231 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size, 231 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size,
232 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 232 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
233 xfs_efi_item_format, 233 xfs_efi_item_format,
@@ -525,7 +525,7 @@ xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn)
525/* 525/*
526 * This is the ops vector shared by all efd log items. 526 * This is the ops vector shared by all efd log items.
527 */ 527 */
528STATIC struct xfs_item_ops xfs_efd_item_ops = { 528static struct xfs_item_ops xfs_efd_item_ops = {
529 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size, 529 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size,
530 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 530 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
531 xfs_efd_item_format, 531 xfs_efd_item_format,
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index c064e72ada9e..32c37c1c47ab 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -250,8 +250,7 @@ xfs_growfs_data_private(
250 block->bb_numrecs = cpu_to_be16(1); 250 block->bb_numrecs = cpu_to_be16(1);
251 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); 251 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
252 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); 252 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
253 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 253 arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1);
254 block, 1, mp->m_alloc_mxr[0]);
255 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); 254 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
256 arec->ar_blockcount = cpu_to_be32( 255 arec->ar_blockcount = cpu_to_be32(
257 agsize - be32_to_cpu(arec->ar_startblock)); 256 agsize - be32_to_cpu(arec->ar_startblock));
@@ -272,8 +271,7 @@ xfs_growfs_data_private(
272 block->bb_numrecs = cpu_to_be16(1); 271 block->bb_numrecs = cpu_to_be16(1);
273 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); 272 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
274 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); 273 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
275 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 274 arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1);
276 block, 1, mp->m_alloc_mxr[0]);
277 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); 275 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
278 arec->ar_blockcount = cpu_to_be32( 276 arec->ar_blockcount = cpu_to_be32(
279 agsize - be32_to_cpu(arec->ar_startblock)); 277 agsize - be32_to_cpu(arec->ar_startblock));
@@ -460,7 +458,7 @@ xfs_fs_counts(
460{ 458{
461 unsigned long s; 459 unsigned long s;
462 460
463 xfs_icsb_sync_counters_lazy(mp); 461 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
464 s = XFS_SB_LOCK(mp); 462 s = XFS_SB_LOCK(mp);
465 cnt->freedata = mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); 463 cnt->freedata = mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
466 cnt->freertx = mp->m_sb.sb_frextents; 464 cnt->freertx = mp->m_sb.sb_frextents;
@@ -491,7 +489,7 @@ xfs_reserve_blocks(
491 __uint64_t *inval, 489 __uint64_t *inval,
492 xfs_fsop_resblks_t *outval) 490 xfs_fsop_resblks_t *outval)
493{ 491{
494 __int64_t lcounter, delta; 492 __int64_t lcounter, delta, fdblks_delta;
495 __uint64_t request; 493 __uint64_t request;
496 unsigned long s; 494 unsigned long s;
497 495
@@ -504,17 +502,35 @@ xfs_reserve_blocks(
504 } 502 }
505 503
506 request = *inval; 504 request = *inval;
505
506 /*
507 * With per-cpu counters, this becomes an interesting
508 * problem. we needto work out if we are freeing or allocation
509 * blocks first, then we can do the modification as necessary.
510 *
511 * We do this under the XFS_SB_LOCK so that if we are near
512 * ENOSPC, we will hold out any changes while we work out
513 * what to do. This means that the amount of free space can
514 * change while we do this, so we need to retry if we end up
515 * trying to reserve more space than is available.
516 *
517 * We also use the xfs_mod_incore_sb() interface so that we
518 * don't have to care about whether per cpu counter are
519 * enabled, disabled or even compiled in....
520 */
521retry:
507 s = XFS_SB_LOCK(mp); 522 s = XFS_SB_LOCK(mp);
523 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_SB_LOCKED);
508 524
509 /* 525 /*
510 * If our previous reservation was larger than the current value, 526 * If our previous reservation was larger than the current value,
511 * then move any unused blocks back to the free pool. 527 * then move any unused blocks back to the free pool.
512 */ 528 */
513 529 fdblks_delta = 0;
514 if (mp->m_resblks > request) { 530 if (mp->m_resblks > request) {
515 lcounter = mp->m_resblks_avail - request; 531 lcounter = mp->m_resblks_avail - request;
516 if (lcounter > 0) { /* release unused blocks */ 532 if (lcounter > 0) { /* release unused blocks */
517 mp->m_sb.sb_fdblocks += lcounter; 533 fdblks_delta = lcounter;
518 mp->m_resblks_avail -= lcounter; 534 mp->m_resblks_avail -= lcounter;
519 } 535 }
520 mp->m_resblks = request; 536 mp->m_resblks = request;
@@ -522,24 +538,50 @@ xfs_reserve_blocks(
522 __int64_t free; 538 __int64_t free;
523 539
524 free = mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); 540 free = mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
541 if (!free)
542 goto out; /* ENOSPC and fdblks_delta = 0 */
543
525 delta = request - mp->m_resblks; 544 delta = request - mp->m_resblks;
526 lcounter = free - delta; 545 lcounter = free - delta;
527 if (lcounter < 0) { 546 if (lcounter < 0) {
528 /* We can't satisfy the request, just get what we can */ 547 /* We can't satisfy the request, just get what we can */
529 mp->m_resblks += free; 548 mp->m_resblks += free;
530 mp->m_resblks_avail += free; 549 mp->m_resblks_avail += free;
550 fdblks_delta = -free;
531 mp->m_sb.sb_fdblocks = XFS_ALLOC_SET_ASIDE(mp); 551 mp->m_sb.sb_fdblocks = XFS_ALLOC_SET_ASIDE(mp);
532 } else { 552 } else {
553 fdblks_delta = -delta;
533 mp->m_sb.sb_fdblocks = 554 mp->m_sb.sb_fdblocks =
534 lcounter + XFS_ALLOC_SET_ASIDE(mp); 555 lcounter + XFS_ALLOC_SET_ASIDE(mp);
535 mp->m_resblks = request; 556 mp->m_resblks = request;
536 mp->m_resblks_avail += delta; 557 mp->m_resblks_avail += delta;
537 } 558 }
538 } 559 }
539 560out:
540 outval->resblks = mp->m_resblks; 561 outval->resblks = mp->m_resblks;
541 outval->resblks_avail = mp->m_resblks_avail; 562 outval->resblks_avail = mp->m_resblks_avail;
542 XFS_SB_UNLOCK(mp, s); 563 XFS_SB_UNLOCK(mp, s);
564
565 if (fdblks_delta) {
566 /*
567 * If we are putting blocks back here, m_resblks_avail is
568 * already at it's max so this will put it in the free pool.
569 *
570 * If we need space, we'll either succeed in getting it
571 * from the free block count or we'll get an enospc. If
572 * we get a ENOSPC, it means things changed while we were
573 * calculating fdblks_delta and so we should try again to
574 * see if there is anything left to reserve.
575 *
576 * Don't set the reserved flag here - we don't want to reserve
577 * the extra reserve blocks from the reserve.....
578 */
579 int error;
580 error = xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, fdblks_delta, 0);
581 if (error == ENOSPC)
582 goto retry;
583 }
584
543 return 0; 585 return 0;
544} 586}
545 587
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index a446e5a115c6..b5feb3e77116 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -342,7 +342,7 @@ xfs_ialloc_ag_alloc(
342 return 0; 342 return 0;
343} 343}
344 344
345STATIC __inline xfs_agnumber_t 345STATIC_INLINE xfs_agnumber_t
346xfs_ialloc_next_ag( 346xfs_ialloc_next_ag(
347 xfs_mount_t *mp) 347 xfs_mount_t *mp)
348{ 348{
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 2c0e49893ff7..bf8e9aff272e 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -89,7 +89,6 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t;
89/* 89/*
90 * Real block structures have a size equal to the disk block size. 90 * Real block structures have a size equal to the disk block size.
91 */ 91 */
92#define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
93#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_inobt_mxr[lev != 0]) 92#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_inobt_mxr[lev != 0])
94#define XFS_INOBT_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_inobt_mnr[lev != 0]) 93#define XFS_INOBT_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_inobt_mnr[lev != 0])
95#define XFS_INOBT_IS_LAST_REC(cur) \ 94#define XFS_INOBT_IS_LAST_REC(cur) \
@@ -110,14 +109,13 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t;
110 * Record, key, and pointer address macros for btree blocks. 109 * Record, key, and pointer address macros for btree blocks.
111 */ 110 */
112#define XFS_INOBT_REC_ADDR(bb,i,cur) \ 111#define XFS_INOBT_REC_ADDR(bb,i,cur) \
113 (XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, \ 112 (XFS_BTREE_REC_ADDR(xfs_inobt, bb, i))
114 i, XFS_INOBT_BLOCK_MAXRECS(0, cur))) 113
115#define XFS_INOBT_KEY_ADDR(bb,i,cur) \ 114#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
116 (XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \ 115 (XFS_BTREE_KEY_ADDR(xfs_inobt, bb, i))
117 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
118 116
119#define XFS_INOBT_PTR_ADDR(bb,i,cur) \ 117#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
120 (XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \ 118 (XFS_BTREE_PTR_ADDR(xfs_inobt, bb, \
121 i, XFS_INOBT_BLOCK_MAXRECS(1, cur))) 119 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
122 120
123/* 121/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 44dfac521285..3da9829c19d5 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -47,7 +47,6 @@
47#include "xfs_utils.h" 47#include "xfs_utils.h"
48#include "xfs_dir2_trace.h" 48#include "xfs_dir2_trace.h"
49#include "xfs_quota.h" 49#include "xfs_quota.h"
50#include "xfs_mac.h"
51#include "xfs_acl.h" 50#include "xfs_acl.h"
52 51
53 52
@@ -1699,8 +1698,7 @@ xfs_itruncate_finish(
1699 * Duplicate the transaction that has the permanent 1698 * Duplicate the transaction that has the permanent
1700 * reservation and commit the old transaction. 1699 * reservation and commit the old transaction.
1701 */ 1700 */
1702 error = xfs_bmap_finish(tp, &free_list, first_block, 1701 error = xfs_bmap_finish(tp, &free_list, &committed);
1703 &committed);
1704 ntp = *tp; 1702 ntp = *tp;
1705 if (error) { 1703 if (error) {
1706 /* 1704 /*
@@ -1810,7 +1808,7 @@ xfs_igrow_start(
1810 * and any blocks between the old and new file sizes. 1808 * and any blocks between the old and new file sizes.
1811 */ 1809 */
1812 error = xfs_zero_eof(XFS_ITOV(ip), &ip->i_iocore, new_size, 1810 error = xfs_zero_eof(XFS_ITOV(ip), &ip->i_iocore, new_size,
1813 ip->i_d.di_size, new_size); 1811 ip->i_d.di_size);
1814 return error; 1812 return error;
1815} 1813}
1816 1814
@@ -2125,7 +2123,7 @@ xfs_iunlink_remove(
2125 return 0; 2123 return 0;
2126} 2124}
2127 2125
2128static __inline__ int xfs_inode_clean(xfs_inode_t *ip) 2126STATIC_INLINE int xfs_inode_clean(xfs_inode_t *ip)
2129{ 2127{
2130 return (((ip->i_itemp == NULL) || 2128 return (((ip->i_itemp == NULL) ||
2131 !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) && 2129 !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) &&
@@ -2707,10 +2705,24 @@ xfs_idestroy(
2707 ktrace_free(ip->i_dir_trace); 2705 ktrace_free(ip->i_dir_trace);
2708#endif 2706#endif
2709 if (ip->i_itemp) { 2707 if (ip->i_itemp) {
2710 /* XXXdpd should be able to assert this but shutdown 2708 /*
2711 * is leaving the AIL behind. */ 2709 * Only if we are shutting down the fs will we see an
2712 ASSERT(((ip->i_itemp->ili_item.li_flags & XFS_LI_IN_AIL) == 0) || 2710 * inode still in the AIL. If it is there, we should remove
2713 XFS_FORCED_SHUTDOWN(ip->i_mount)); 2711 * it to prevent a use-after-free from occurring.
2712 */
2713 xfs_mount_t *mp = ip->i_mount;
2714 xfs_log_item_t *lip = &ip->i_itemp->ili_item;
2715 int s;
2716
2717 ASSERT(((lip->li_flags & XFS_LI_IN_AIL) == 0) ||
2718 XFS_FORCED_SHUTDOWN(ip->i_mount));
2719 if (lip->li_flags & XFS_LI_IN_AIL) {
2720 AIL_LOCK(mp, s);
2721 if (lip->li_flags & XFS_LI_IN_AIL)
2722 xfs_trans_delete_ail(mp, lip, s);
2723 else
2724 AIL_UNLOCK(mp, s);
2725 }
2714 xfs_inode_item_destroy(ip); 2726 xfs_inode_item_destroy(ip);
2715 } 2727 }
2716 kmem_zone_free(xfs_inode_zone, ip); 2728 kmem_zone_free(xfs_inode_zone, ip);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a7a92251eb56..565d470a6b4a 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -887,7 +887,7 @@ xfs_inode_item_committing(
887/* 887/*
888 * This is the ops vector shared by all buf log items. 888 * This is the ops vector shared by all buf log items.
889 */ 889 */
890STATIC struct xfs_item_ops xfs_inode_item_ops = { 890static struct xfs_item_ops xfs_inode_item_ops = {
891 .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size, 891 .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size,
892 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 892 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
893 xfs_inode_item_format, 893 xfs_inode_item_format,
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 19655124da78..cc6a7b5a9912 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -43,8 +43,6 @@
43#include "xfs_itable.h" 43#include "xfs_itable.h"
44#include "xfs_rw.h" 44#include "xfs_rw.h"
45#include "xfs_acl.h" 45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h" 46#include "xfs_attr.h"
49#include "xfs_buf_item.h" 47#include "xfs_buf_item.h"
50#include "xfs_trans_space.h" 48#include "xfs_trans_space.h"
@@ -542,7 +540,7 @@ xfs_iomap_write_direct(
542 /* 540 /*
543 * Complete the transaction 541 * Complete the transaction
544 */ 542 */
545 error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed); 543 error = xfs_bmap_finish(&tp, &free_list, &committed);
546 if (error) 544 if (error)
547 goto error0; 545 goto error0;
548 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 546 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
@@ -838,8 +836,7 @@ xfs_iomap_write_allocate(
838 if (error) 836 if (error)
839 goto trans_cancel; 837 goto trans_cancel;
840 838
841 error = xfs_bmap_finish(&tp, &free_list, 839 error = xfs_bmap_finish(&tp, &free_list, &committed);
842 first_block, &committed);
843 if (error) 840 if (error)
844 goto trans_cancel; 841 goto trans_cancel;
845 842
@@ -947,8 +944,7 @@ xfs_iomap_write_unwritten(
947 if (error) 944 if (error)
948 goto error_on_bmapi_transaction; 945 goto error_on_bmapi_transaction;
949 946
950 error = xfs_bmap_finish(&(tp), &(free_list), 947 error = xfs_bmap_finish(&(tp), &(free_list), &committed);
951 firstfsb, &committed);
952 if (error) 948 if (error)
953 goto error_on_bmapi_transaction; 949 goto error_on_bmapi_transaction;
954 950
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 3cb678e3a132..ca74d3f5910e 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1514,7 +1514,6 @@ xlog_recover_reorder_trans(
1514{ 1514{
1515 xlog_recover_item_t *first_item, *itemq, *itemq_next; 1515 xlog_recover_item_t *first_item, *itemq, *itemq_next;
1516 xfs_buf_log_format_t *buf_f; 1516 xfs_buf_log_format_t *buf_f;
1517 xfs_buf_log_format_v1_t *obuf_f;
1518 ushort flags = 0; 1517 ushort flags = 0;
1519 1518
1520 first_item = itemq = trans->r_itemq; 1519 first_item = itemq = trans->r_itemq;
@@ -1522,29 +1521,16 @@ xlog_recover_reorder_trans(
1522 do { 1521 do {
1523 itemq_next = itemq->ri_next; 1522 itemq_next = itemq->ri_next;
1524 buf_f = (xfs_buf_log_format_t *)itemq->ri_buf[0].i_addr; 1523 buf_f = (xfs_buf_log_format_t *)itemq->ri_buf[0].i_addr;
1525 switch (ITEM_TYPE(itemq)) {
1526 case XFS_LI_BUF:
1527 flags = buf_f->blf_flags;
1528 break;
1529 case XFS_LI_6_1_BUF:
1530 case XFS_LI_5_3_BUF:
1531 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
1532 flags = obuf_f->blf_flags;
1533 break;
1534 }
1535 1524
1536 switch (ITEM_TYPE(itemq)) { 1525 switch (ITEM_TYPE(itemq)) {
1537 case XFS_LI_BUF: 1526 case XFS_LI_BUF:
1538 case XFS_LI_6_1_BUF: 1527 flags = buf_f->blf_flags;
1539 case XFS_LI_5_3_BUF:
1540 if (!(flags & XFS_BLI_CANCEL)) { 1528 if (!(flags & XFS_BLI_CANCEL)) {
1541 xlog_recover_insert_item_frontq(&trans->r_itemq, 1529 xlog_recover_insert_item_frontq(&trans->r_itemq,
1542 itemq); 1530 itemq);
1543 break; 1531 break;
1544 } 1532 }
1545 case XFS_LI_INODE: 1533 case XFS_LI_INODE:
1546 case XFS_LI_6_1_INODE:
1547 case XFS_LI_5_3_INODE:
1548 case XFS_LI_DQUOT: 1534 case XFS_LI_DQUOT:
1549 case XFS_LI_QUOTAOFF: 1535 case XFS_LI_QUOTAOFF:
1550 case XFS_LI_EFD: 1536 case XFS_LI_EFD:
@@ -1583,7 +1569,6 @@ xlog_recover_do_buffer_pass1(
1583 xfs_buf_cancel_t *nextp; 1569 xfs_buf_cancel_t *nextp;
1584 xfs_buf_cancel_t *prevp; 1570 xfs_buf_cancel_t *prevp;
1585 xfs_buf_cancel_t **bucket; 1571 xfs_buf_cancel_t **bucket;
1586 xfs_buf_log_format_v1_t *obuf_f;
1587 xfs_daddr_t blkno = 0; 1572 xfs_daddr_t blkno = 0;
1588 uint len = 0; 1573 uint len = 0;
1589 ushort flags = 0; 1574 ushort flags = 0;
@@ -1594,13 +1579,6 @@ xlog_recover_do_buffer_pass1(
1594 len = buf_f->blf_len; 1579 len = buf_f->blf_len;
1595 flags = buf_f->blf_flags; 1580 flags = buf_f->blf_flags;
1596 break; 1581 break;
1597 case XFS_LI_6_1_BUF:
1598 case XFS_LI_5_3_BUF:
1599 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
1600 blkno = (xfs_daddr_t) obuf_f->blf_blkno;
1601 len = obuf_f->blf_len;
1602 flags = obuf_f->blf_flags;
1603 break;
1604 } 1582 }
1605 1583
1606 /* 1584 /*
@@ -1746,7 +1724,6 @@ xlog_recover_do_buffer_pass2(
1746 xlog_t *log, 1724 xlog_t *log,
1747 xfs_buf_log_format_t *buf_f) 1725 xfs_buf_log_format_t *buf_f)
1748{ 1726{
1749 xfs_buf_log_format_v1_t *obuf_f;
1750 xfs_daddr_t blkno = 0; 1727 xfs_daddr_t blkno = 0;
1751 ushort flags = 0; 1728 ushort flags = 0;
1752 uint len = 0; 1729 uint len = 0;
@@ -1757,13 +1734,6 @@ xlog_recover_do_buffer_pass2(
1757 flags = buf_f->blf_flags; 1734 flags = buf_f->blf_flags;
1758 len = buf_f->blf_len; 1735 len = buf_f->blf_len;
1759 break; 1736 break;
1760 case XFS_LI_6_1_BUF:
1761 case XFS_LI_5_3_BUF:
1762 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
1763 blkno = (xfs_daddr_t) obuf_f->blf_blkno;
1764 flags = obuf_f->blf_flags;
1765 len = (xfs_daddr_t) obuf_f->blf_len;
1766 break;
1767 } 1737 }
1768 1738
1769 return xlog_check_buffer_cancelled(log, blkno, len, flags); 1739 return xlog_check_buffer_cancelled(log, blkno, len, flags);
@@ -1799,7 +1769,6 @@ xlog_recover_do_inode_buffer(
1799 int inodes_per_buf; 1769 int inodes_per_buf;
1800 xfs_agino_t *logged_nextp; 1770 xfs_agino_t *logged_nextp;
1801 xfs_agino_t *buffer_nextp; 1771 xfs_agino_t *buffer_nextp;
1802 xfs_buf_log_format_v1_t *obuf_f;
1803 unsigned int *data_map = NULL; 1772 unsigned int *data_map = NULL;
1804 unsigned int map_size = 0; 1773 unsigned int map_size = 0;
1805 1774
@@ -1808,12 +1777,6 @@ xlog_recover_do_inode_buffer(
1808 data_map = buf_f->blf_data_map; 1777 data_map = buf_f->blf_data_map;
1809 map_size = buf_f->blf_map_size; 1778 map_size = buf_f->blf_map_size;
1810 break; 1779 break;
1811 case XFS_LI_6_1_BUF:
1812 case XFS_LI_5_3_BUF:
1813 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
1814 data_map = obuf_f->blf_data_map;
1815 map_size = obuf_f->blf_map_size;
1816 break;
1817 } 1780 }
1818 /* 1781 /*
1819 * Set the variables corresponding to the current region to 1782 * Set the variables corresponding to the current region to
@@ -1912,7 +1875,6 @@ xlog_recover_do_reg_buffer(
1912 int i; 1875 int i;
1913 int bit; 1876 int bit;
1914 int nbits; 1877 int nbits;
1915 xfs_buf_log_format_v1_t *obuf_f;
1916 unsigned int *data_map = NULL; 1878 unsigned int *data_map = NULL;
1917 unsigned int map_size = 0; 1879 unsigned int map_size = 0;
1918 int error; 1880 int error;
@@ -1922,12 +1884,6 @@ xlog_recover_do_reg_buffer(
1922 data_map = buf_f->blf_data_map; 1884 data_map = buf_f->blf_data_map;
1923 map_size = buf_f->blf_map_size; 1885 map_size = buf_f->blf_map_size;
1924 break; 1886 break;
1925 case XFS_LI_6_1_BUF:
1926 case XFS_LI_5_3_BUF:
1927 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
1928 data_map = obuf_f->blf_data_map;
1929 map_size = obuf_f->blf_map_size;
1930 break;
1931 } 1887 }
1932 bit = 0; 1888 bit = 0;
1933 i = 1; /* 0 is the buf format structure */ 1889 i = 1; /* 0 is the buf format structure */
@@ -2160,7 +2116,6 @@ xlog_recover_do_buffer_trans(
2160 int pass) 2116 int pass)
2161{ 2117{
2162 xfs_buf_log_format_t *buf_f; 2118 xfs_buf_log_format_t *buf_f;
2163 xfs_buf_log_format_v1_t *obuf_f;
2164 xfs_mount_t *mp; 2119 xfs_mount_t *mp;
2165 xfs_buf_t *bp; 2120 xfs_buf_t *bp;
2166 int error; 2121 int error;
@@ -2197,13 +2152,6 @@ xlog_recover_do_buffer_trans(
2197 len = buf_f->blf_len; 2152 len = buf_f->blf_len;
2198 flags = buf_f->blf_flags; 2153 flags = buf_f->blf_flags;
2199 break; 2154 break;
2200 case XFS_LI_6_1_BUF:
2201 case XFS_LI_5_3_BUF:
2202 obuf_f = (xfs_buf_log_format_v1_t*)buf_f;
2203 blkno = obuf_f->blf_blkno;
2204 len = obuf_f->blf_len;
2205 flags = obuf_f->blf_flags;
2206 break;
2207 default: 2155 default:
2208 xfs_fs_cmn_err(CE_ALERT, log->l_mp, 2156 xfs_fs_cmn_err(CE_ALERT, log->l_mp,
2209 "xfs_log_recover: unknown buffer type 0x%x, logdev %s", 2157 "xfs_log_recover: unknown buffer type 0x%x, logdev %s",
@@ -2830,9 +2778,7 @@ xlog_recover_do_trans(
2830 * where xfs_daddr_t is 32-bits but mount will warn us 2778 * where xfs_daddr_t is 32-bits but mount will warn us
2831 * off a > 1 TB filesystem before we get here. 2779 * off a > 1 TB filesystem before we get here.
2832 */ 2780 */
2833 if ((ITEM_TYPE(item) == XFS_LI_BUF) || 2781 if ((ITEM_TYPE(item) == XFS_LI_BUF)) {
2834 (ITEM_TYPE(item) == XFS_LI_6_1_BUF) ||
2835 (ITEM_TYPE(item) == XFS_LI_5_3_BUF)) {
2836 if ((error = xlog_recover_do_buffer_trans(log, item, 2782 if ((error = xlog_recover_do_buffer_trans(log, item,
2837 pass))) 2783 pass)))
2838 break; 2784 break;
@@ -3902,6 +3848,9 @@ xlog_do_recover(
3902 ASSERT(XFS_SB_GOOD_VERSION(sbp)); 3848 ASSERT(XFS_SB_GOOD_VERSION(sbp));
3903 xfs_buf_relse(bp); 3849 xfs_buf_relse(bp);
3904 3850
3851 /* We've re-read the superblock so re-initialize per-cpu counters */
3852 xfs_icsb_reinit_counters(log->l_mp);
3853
3905 xlog_recover_check_summary(log); 3854 xlog_recover_check_summary(log);
3906 3855
3907 /* Normal transactions can now occur */ 3856 /* Normal transactions can now occur */
diff --git a/fs/xfs/xfs_mac.h b/fs/xfs/xfs_mac.h
deleted file mode 100644
index 18e0e98e03d0..000000000000
--- a/fs/xfs/xfs_mac.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/*
2 * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_MAC_H__
19#define __XFS_MAC_H__
20
21/*
22 * Mandatory Access Control
23 *
24 * Layout of a composite MAC label:
25 * ml_list contains the list of categories (MSEN) followed by the list of
26 * divisions (MINT). This is actually a header for the data structure which
27 * will have an ml_list with more than one element.
28 *
29 * -------------------------------
30 * | ml_msen_type | ml_mint_type |
31 * -------------------------------
32 * | ml_level | ml_grade |
33 * -------------------------------
34 * | ml_catcount |
35 * -------------------------------
36 * | ml_divcount |
37 * -------------------------------
38 * | category 1 |
39 * | . . . |
40 * | category N | (where N = ml_catcount)
41 * -------------------------------
42 * | division 1 |
43 * | . . . |
44 * | division M | (where M = ml_divcount)
45 * -------------------------------
46 */
47#define XFS_MAC_MAX_SETS 250
48typedef struct xfs_mac_label {
49 __uint8_t ml_msen_type; /* MSEN label type */
50 __uint8_t ml_mint_type; /* MINT label type */
51 __uint8_t ml_level; /* Hierarchical level */
52 __uint8_t ml_grade; /* Hierarchical grade */
53 __uint16_t ml_catcount; /* Category count */
54 __uint16_t ml_divcount; /* Division count */
55 /* Category set, then Division set */
56 __uint16_t ml_list[XFS_MAC_MAX_SETS];
57} xfs_mac_label_t;
58
59/* MSEN label type names. Choose an upper case ASCII character. */
60#define XFS_MSEN_ADMIN_LABEL 'A' /* Admin: low<admin != tcsec<high */
61#define XFS_MSEN_EQUAL_LABEL 'E' /* Wildcard - always equal */
62#define XFS_MSEN_HIGH_LABEL 'H' /* System High - always dominates */
63#define XFS_MSEN_MLD_HIGH_LABEL 'I' /* System High, multi-level dir */
64#define XFS_MSEN_LOW_LABEL 'L' /* System Low - always dominated */
65#define XFS_MSEN_MLD_LABEL 'M' /* TCSEC label on a multi-level dir */
66#define XFS_MSEN_MLD_LOW_LABEL 'N' /* System Low, multi-level dir */
67#define XFS_MSEN_TCSEC_LABEL 'T' /* TCSEC label */
68#define XFS_MSEN_UNKNOWN_LABEL 'U' /* unknown label */
69
70/* MINT label type names. Choose a lower case ASCII character. */
71#define XFS_MINT_BIBA_LABEL 'b' /* Dual of a TCSEC label */
72#define XFS_MINT_EQUAL_LABEL 'e' /* Wildcard - always equal */
73#define XFS_MINT_HIGH_LABEL 'h' /* High Grade - always dominates */
74#define XFS_MINT_LOW_LABEL 'l' /* Low Grade - always dominated */
75
76/* On-disk XFS extended attribute names */
77#define SGI_MAC_FILE "SGI_MAC_FILE"
78#define SGI_MAC_FILE_SIZE (sizeof(SGI_MAC_FILE)-1)
79
80
81#ifdef __KERNEL__
82
83#ifdef CONFIG_FS_POSIX_MAC
84
85/* NOT YET IMPLEMENTED */
86
87#define MACEXEC 00100
88#define MACWRITE 00200
89#define MACREAD 00400
90
91struct xfs_inode;
92extern int xfs_mac_iaccess(struct xfs_inode *, mode_t, cred_t *);
93
94#define _MAC_XFS_IACCESS(i,m,c) (xfs_mac_iaccess(i,m,c))
95#define _MAC_VACCESS(v,c,m) (xfs_mac_vaccess(v,c,m))
96#define _MAC_EXISTS xfs_mac_vhaslabel
97
98#else
99#define _MAC_XFS_IACCESS(i,m,c) (0)
100#define _MAC_VACCESS(v,c,m) (0)
101#define _MAC_EXISTS (NULL)
102#endif
103
104#endif /* __KERNEL__ */
105
106#endif /* __XFS_MAC_H__ */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 9dfae18d995f..3bed0cf0d8af 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -52,21 +52,19 @@ STATIC void xfs_unmountfs_wait(xfs_mount_t *);
52 52
53#ifdef HAVE_PERCPU_SB 53#ifdef HAVE_PERCPU_SB
54STATIC void xfs_icsb_destroy_counters(xfs_mount_t *); 54STATIC void xfs_icsb_destroy_counters(xfs_mount_t *);
55STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, int); 55STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
56 int, int);
56STATIC void xfs_icsb_sync_counters(xfs_mount_t *); 57STATIC void xfs_icsb_sync_counters(xfs_mount_t *);
57STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t, 58STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
58 int, int); 59 int64_t, int);
59STATIC int xfs_icsb_modify_counters_locked(xfs_mount_t *, xfs_sb_field_t,
60 int, int);
61STATIC int xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t); 60STATIC int xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t);
62 61
63#else 62#else
64 63
65#define xfs_icsb_destroy_counters(mp) do { } while (0) 64#define xfs_icsb_destroy_counters(mp) do { } while (0)
66#define xfs_icsb_balance_counter(mp, a, b) do { } while (0) 65#define xfs_icsb_balance_counter(mp, a, b, c) do { } while (0)
67#define xfs_icsb_sync_counters(mp) do { } while (0) 66#define xfs_icsb_sync_counters(mp) do { } while (0)
68#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0) 67#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
69#define xfs_icsb_modify_counters_locked(mp, a, b, c) do { } while (0)
70 68
71#endif 69#endif
72 70
@@ -545,9 +543,8 @@ xfs_readsb(xfs_mount_t *mp, int flags)
545 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); 543 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
546 } 544 }
547 545
548 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0); 546 /* Initialize per-cpu counters */
549 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0); 547 xfs_icsb_reinit_counters(mp);
550 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
551 548
552 mp->m_sb_bp = bp; 549 mp->m_sb_bp = bp;
553 xfs_buf_relse(bp); 550 xfs_buf_relse(bp);
@@ -1254,8 +1251,11 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
1254 * The SB_LOCK must be held when this routine is called. 1251 * The SB_LOCK must be held when this routine is called.
1255 */ 1252 */
1256int 1253int
1257xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field, 1254xfs_mod_incore_sb_unlocked(
1258 int delta, int rsvd) 1255 xfs_mount_t *mp,
1256 xfs_sb_field_t field,
1257 int64_t delta,
1258 int rsvd)
1259{ 1259{
1260 int scounter; /* short counter for 32 bit fields */ 1260 int scounter; /* short counter for 32 bit fields */
1261 long long lcounter; /* long counter for 64 bit fields */ 1261 long long lcounter; /* long counter for 64 bit fields */
@@ -1287,7 +1287,6 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
1287 mp->m_sb.sb_ifree = lcounter; 1287 mp->m_sb.sb_ifree = lcounter;
1288 return 0; 1288 return 0;
1289 case XFS_SBS_FDBLOCKS: 1289 case XFS_SBS_FDBLOCKS:
1290
1291 lcounter = (long long) 1290 lcounter = (long long)
1292 mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); 1291 mp->m_sb.sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
1293 res_used = (long long)(mp->m_resblks - mp->m_resblks_avail); 1292 res_used = (long long)(mp->m_resblks - mp->m_resblks_avail);
@@ -1418,7 +1417,11 @@ xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
1418 * routine to do the work. 1417 * routine to do the work.
1419 */ 1418 */
1420int 1419int
1421xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd) 1420xfs_mod_incore_sb(
1421 xfs_mount_t *mp,
1422 xfs_sb_field_t field,
1423 int64_t delta,
1424 int rsvd)
1422{ 1425{
1423 unsigned long s; 1426 unsigned long s;
1424 int status; 1427 int status;
@@ -1485,9 +1488,11 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
1485 case XFS_SBS_IFREE: 1488 case XFS_SBS_IFREE:
1486 case XFS_SBS_FDBLOCKS: 1489 case XFS_SBS_FDBLOCKS:
1487 if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { 1490 if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) {
1488 status = xfs_icsb_modify_counters_locked(mp, 1491 XFS_SB_UNLOCK(mp, s);
1492 status = xfs_icsb_modify_counters(mp,
1489 msbp->msb_field, 1493 msbp->msb_field,
1490 msbp->msb_delta, rsvd); 1494 msbp->msb_delta, rsvd);
1495 s = XFS_SB_LOCK(mp);
1491 break; 1496 break;
1492 } 1497 }
1493 /* FALLTHROUGH */ 1498 /* FALLTHROUGH */
@@ -1521,11 +1526,12 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
1521 case XFS_SBS_IFREE: 1526 case XFS_SBS_IFREE:
1522 case XFS_SBS_FDBLOCKS: 1527 case XFS_SBS_FDBLOCKS:
1523 if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) { 1528 if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) {
1524 status = 1529 XFS_SB_UNLOCK(mp, s);
1525 xfs_icsb_modify_counters_locked(mp, 1530 status = xfs_icsb_modify_counters(mp,
1526 msbp->msb_field, 1531 msbp->msb_field,
1527 -(msbp->msb_delta), 1532 -(msbp->msb_delta),
1528 rsvd); 1533 rsvd);
1534 s = XFS_SB_LOCK(mp);
1529 break; 1535 break;
1530 } 1536 }
1531 /* FALLTHROUGH */ 1537 /* FALLTHROUGH */
@@ -1733,14 +1739,17 @@ xfs_icsb_cpu_notify(
1733 memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); 1739 memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
1734 break; 1740 break;
1735 case CPU_ONLINE: 1741 case CPU_ONLINE:
1736 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0); 1742 xfs_icsb_lock(mp);
1737 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0); 1743 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0);
1738 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0); 1744 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0);
1745 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0);
1746 xfs_icsb_unlock(mp);
1739 break; 1747 break;
1740 case CPU_DEAD: 1748 case CPU_DEAD:
1741 /* Disable all the counters, then fold the dead cpu's 1749 /* Disable all the counters, then fold the dead cpu's
1742 * count into the total on the global superblock and 1750 * count into the total on the global superblock and
1743 * re-enable the counters. */ 1751 * re-enable the counters. */
1752 xfs_icsb_lock(mp);
1744 s = XFS_SB_LOCK(mp); 1753 s = XFS_SB_LOCK(mp);
1745 xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT); 1754 xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT);
1746 xfs_icsb_disable_counter(mp, XFS_SBS_IFREE); 1755 xfs_icsb_disable_counter(mp, XFS_SBS_IFREE);
@@ -1752,10 +1761,14 @@ xfs_icsb_cpu_notify(
1752 1761
1753 memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); 1762 memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
1754 1763
1755 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, XFS_ICSB_SB_LOCKED); 1764 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT,
1756 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, XFS_ICSB_SB_LOCKED); 1765 XFS_ICSB_SB_LOCKED, 0);
1757 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, XFS_ICSB_SB_LOCKED); 1766 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE,
1767 XFS_ICSB_SB_LOCKED, 0);
1768 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS,
1769 XFS_ICSB_SB_LOCKED, 0);
1758 XFS_SB_UNLOCK(mp, s); 1770 XFS_SB_UNLOCK(mp, s);
1771 xfs_icsb_unlock(mp);
1759 break; 1772 break;
1760 } 1773 }
1761 1774
@@ -1784,6 +1797,9 @@ xfs_icsb_init_counters(
1784 cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i); 1797 cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
1785 memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); 1798 memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
1786 } 1799 }
1800
1801 mutex_init(&mp->m_icsb_mutex);
1802
1787 /* 1803 /*
1788 * start with all counters disabled so that the 1804 * start with all counters disabled so that the
1789 * initial balance kicks us off correctly 1805 * initial balance kicks us off correctly
@@ -1792,6 +1808,22 @@ xfs_icsb_init_counters(
1792 return 0; 1808 return 0;
1793} 1809}
1794 1810
1811void
1812xfs_icsb_reinit_counters(
1813 xfs_mount_t *mp)
1814{
1815 xfs_icsb_lock(mp);
1816 /*
1817 * start with all counters disabled so that the
1818 * initial balance kicks us off correctly
1819 */
1820 mp->m_icsb_counters = -1;
1821 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0);
1822 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0);
1823 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0);
1824 xfs_icsb_unlock(mp);
1825}
1826
1795STATIC void 1827STATIC void
1796xfs_icsb_destroy_counters( 1828xfs_icsb_destroy_counters(
1797 xfs_mount_t *mp) 1829 xfs_mount_t *mp)
@@ -1800,9 +1832,10 @@ xfs_icsb_destroy_counters(
1800 unregister_hotcpu_notifier(&mp->m_icsb_notifier); 1832 unregister_hotcpu_notifier(&mp->m_icsb_notifier);
1801 free_percpu(mp->m_sb_cnts); 1833 free_percpu(mp->m_sb_cnts);
1802 } 1834 }
1835 mutex_destroy(&mp->m_icsb_mutex);
1803} 1836}
1804 1837
1805STATIC inline void 1838STATIC_INLINE void
1806xfs_icsb_lock_cntr( 1839xfs_icsb_lock_cntr(
1807 xfs_icsb_cnts_t *icsbp) 1840 xfs_icsb_cnts_t *icsbp)
1808{ 1841{
@@ -1811,7 +1844,7 @@ xfs_icsb_lock_cntr(
1811 } 1844 }
1812} 1845}
1813 1846
1814STATIC inline void 1847STATIC_INLINE void
1815xfs_icsb_unlock_cntr( 1848xfs_icsb_unlock_cntr(
1816 xfs_icsb_cnts_t *icsbp) 1849 xfs_icsb_cnts_t *icsbp)
1817{ 1850{
@@ -1819,7 +1852,7 @@ xfs_icsb_unlock_cntr(
1819} 1852}
1820 1853
1821 1854
1822STATIC inline void 1855STATIC_INLINE void
1823xfs_icsb_lock_all_counters( 1856xfs_icsb_lock_all_counters(
1824 xfs_mount_t *mp) 1857 xfs_mount_t *mp)
1825{ 1858{
@@ -1832,7 +1865,7 @@ xfs_icsb_lock_all_counters(
1832 } 1865 }
1833} 1866}
1834 1867
1835STATIC inline void 1868STATIC_INLINE void
1836xfs_icsb_unlock_all_counters( 1869xfs_icsb_unlock_all_counters(
1837 xfs_mount_t *mp) 1870 xfs_mount_t *mp)
1838{ 1871{
@@ -1888,6 +1921,17 @@ xfs_icsb_disable_counter(
1888 1921
1889 ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS)); 1922 ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS));
1890 1923
1924 /*
1925 * If we are already disabled, then there is nothing to do
1926 * here. We check before locking all the counters to avoid
1927 * the expensive lock operation when being called in the
1928 * slow path and the counter is already disabled. This is
1929 * safe because the only time we set or clear this state is under
1930 * the m_icsb_mutex.
1931 */
1932 if (xfs_icsb_counter_disabled(mp, field))
1933 return 0;
1934
1891 xfs_icsb_lock_all_counters(mp); 1935 xfs_icsb_lock_all_counters(mp);
1892 if (!test_and_set_bit(field, &mp->m_icsb_counters)) { 1936 if (!test_and_set_bit(field, &mp->m_icsb_counters)) {
1893 /* drain back to superblock */ 1937 /* drain back to superblock */
@@ -1948,8 +1992,8 @@ xfs_icsb_enable_counter(
1948 xfs_icsb_unlock_all_counters(mp); 1992 xfs_icsb_unlock_all_counters(mp);
1949} 1993}
1950 1994
1951STATIC void 1995void
1952xfs_icsb_sync_counters_int( 1996xfs_icsb_sync_counters_flags(
1953 xfs_mount_t *mp, 1997 xfs_mount_t *mp,
1954 int flags) 1998 int flags)
1955{ 1999{
@@ -1981,40 +2025,39 @@ STATIC void
1981xfs_icsb_sync_counters( 2025xfs_icsb_sync_counters(
1982 xfs_mount_t *mp) 2026 xfs_mount_t *mp)
1983{ 2027{
1984 xfs_icsb_sync_counters_int(mp, 0); 2028 xfs_icsb_sync_counters_flags(mp, 0);
1985}
1986
1987/*
1988 * lazy addition used for things like df, background sb syncs, etc
1989 */
1990void
1991xfs_icsb_sync_counters_lazy(
1992 xfs_mount_t *mp)
1993{
1994 xfs_icsb_sync_counters_int(mp, XFS_ICSB_LAZY_COUNT);
1995} 2029}
1996 2030
1997/* 2031/*
1998 * Balance and enable/disable counters as necessary. 2032 * Balance and enable/disable counters as necessary.
1999 * 2033 *
2000 * Thresholds for re-enabling counters are somewhat magic. 2034 * Thresholds for re-enabling counters are somewhat magic. inode counts are
2001 * inode counts are chosen to be the same number as single 2035 * chosen to be the same number as single on disk allocation chunk per CPU, and
2002 * on disk allocation chunk per CPU, and free blocks is 2036 * free blocks is something far enough zero that we aren't going thrash when we
2003 * something far enough zero that we aren't going thrash 2037 * get near ENOSPC. We also need to supply a minimum we require per cpu to
2004 * when we get near ENOSPC. 2038 * prevent looping endlessly when xfs_alloc_space asks for more than will
2039 * be distributed to a single CPU but each CPU has enough blocks to be
2040 * reenabled.
2041 *
2042 * Note that we can be called when counters are already disabled.
2043 * xfs_icsb_disable_counter() optimises the counter locking in this case to
2044 * prevent locking every per-cpu counter needlessly.
2005 */ 2045 */
2006#define XFS_ICSB_INO_CNTR_REENABLE 64 2046
2047#define XFS_ICSB_INO_CNTR_REENABLE (uint64_t)64
2007#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \ 2048#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \
2008 (512 + XFS_ALLOC_SET_ASIDE(mp)) 2049 (uint64_t)(512 + XFS_ALLOC_SET_ASIDE(mp))
2009STATIC void 2050STATIC void
2010xfs_icsb_balance_counter( 2051xfs_icsb_balance_counter(
2011 xfs_mount_t *mp, 2052 xfs_mount_t *mp,
2012 xfs_sb_field_t field, 2053 xfs_sb_field_t field,
2013 int flags) 2054 int flags,
2055 int min_per_cpu)
2014{ 2056{
2015 uint64_t count, resid; 2057 uint64_t count, resid;
2016 int weight = num_online_cpus(); 2058 int weight = num_online_cpus();
2017 int s; 2059 int s;
2060 uint64_t min = (uint64_t)min_per_cpu;
2018 2061
2019 if (!(flags & XFS_ICSB_SB_LOCKED)) 2062 if (!(flags & XFS_ICSB_SB_LOCKED))
2020 s = XFS_SB_LOCK(mp); 2063 s = XFS_SB_LOCK(mp);
@@ -2027,19 +2070,19 @@ xfs_icsb_balance_counter(
2027 case XFS_SBS_ICOUNT: 2070 case XFS_SBS_ICOUNT:
2028 count = mp->m_sb.sb_icount; 2071 count = mp->m_sb.sb_icount;
2029 resid = do_div(count, weight); 2072 resid = do_div(count, weight);
2030 if (count < XFS_ICSB_INO_CNTR_REENABLE) 2073 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
2031 goto out; 2074 goto out;
2032 break; 2075 break;
2033 case XFS_SBS_IFREE: 2076 case XFS_SBS_IFREE:
2034 count = mp->m_sb.sb_ifree; 2077 count = mp->m_sb.sb_ifree;
2035 resid = do_div(count, weight); 2078 resid = do_div(count, weight);
2036 if (count < XFS_ICSB_INO_CNTR_REENABLE) 2079 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
2037 goto out; 2080 goto out;
2038 break; 2081 break;
2039 case XFS_SBS_FDBLOCKS: 2082 case XFS_SBS_FDBLOCKS:
2040 count = mp->m_sb.sb_fdblocks; 2083 count = mp->m_sb.sb_fdblocks;
2041 resid = do_div(count, weight); 2084 resid = do_div(count, weight);
2042 if (count < XFS_ICSB_FDBLK_CNTR_REENABLE(mp)) 2085 if (count < max(min, XFS_ICSB_FDBLK_CNTR_REENABLE(mp)))
2043 goto out; 2086 goto out;
2044 break; 2087 break;
2045 default: 2088 default:
@@ -2054,32 +2097,39 @@ out:
2054 XFS_SB_UNLOCK(mp, s); 2097 XFS_SB_UNLOCK(mp, s);
2055} 2098}
2056 2099
2057STATIC int 2100int
2058xfs_icsb_modify_counters_int( 2101xfs_icsb_modify_counters(
2059 xfs_mount_t *mp, 2102 xfs_mount_t *mp,
2060 xfs_sb_field_t field, 2103 xfs_sb_field_t field,
2061 int delta, 2104 int64_t delta,
2062 int rsvd, 2105 int rsvd)
2063 int flags)
2064{ 2106{
2065 xfs_icsb_cnts_t *icsbp; 2107 xfs_icsb_cnts_t *icsbp;
2066 long long lcounter; /* long counter for 64 bit fields */ 2108 long long lcounter; /* long counter for 64 bit fields */
2067 int cpu, s, locked = 0; 2109 int cpu, ret = 0, s;
2068 int ret = 0, balance_done = 0;
2069 2110
2111 might_sleep();
2070again: 2112again:
2071 cpu = get_cpu(); 2113 cpu = get_cpu();
2072 icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu), 2114 icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu);
2073 xfs_icsb_lock_cntr(icsbp); 2115
2116 /*
2117 * if the counter is disabled, go to slow path
2118 */
2074 if (unlikely(xfs_icsb_counter_disabled(mp, field))) 2119 if (unlikely(xfs_icsb_counter_disabled(mp, field)))
2075 goto slow_path; 2120 goto slow_path;
2121 xfs_icsb_lock_cntr(icsbp);
2122 if (unlikely(xfs_icsb_counter_disabled(mp, field))) {
2123 xfs_icsb_unlock_cntr(icsbp);
2124 goto slow_path;
2125 }
2076 2126
2077 switch (field) { 2127 switch (field) {
2078 case XFS_SBS_ICOUNT: 2128 case XFS_SBS_ICOUNT:
2079 lcounter = icsbp->icsb_icount; 2129 lcounter = icsbp->icsb_icount;
2080 lcounter += delta; 2130 lcounter += delta;
2081 if (unlikely(lcounter < 0)) 2131 if (unlikely(lcounter < 0))
2082 goto slow_path; 2132 goto balance_counter;
2083 icsbp->icsb_icount = lcounter; 2133 icsbp->icsb_icount = lcounter;
2084 break; 2134 break;
2085 2135
@@ -2087,7 +2137,7 @@ again:
2087 lcounter = icsbp->icsb_ifree; 2137 lcounter = icsbp->icsb_ifree;
2088 lcounter += delta; 2138 lcounter += delta;
2089 if (unlikely(lcounter < 0)) 2139 if (unlikely(lcounter < 0))
2090 goto slow_path; 2140 goto balance_counter;
2091 icsbp->icsb_ifree = lcounter; 2141 icsbp->icsb_ifree = lcounter;
2092 break; 2142 break;
2093 2143
@@ -2097,7 +2147,7 @@ again:
2097 lcounter = icsbp->icsb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); 2147 lcounter = icsbp->icsb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
2098 lcounter += delta; 2148 lcounter += delta;
2099 if (unlikely(lcounter < 0)) 2149 if (unlikely(lcounter < 0))
2100 goto slow_path; 2150 goto balance_counter;
2101 icsbp->icsb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp); 2151 icsbp->icsb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp);
2102 break; 2152 break;
2103 default: 2153 default:
@@ -2106,72 +2156,78 @@ again:
2106 } 2156 }
2107 xfs_icsb_unlock_cntr(icsbp); 2157 xfs_icsb_unlock_cntr(icsbp);
2108 put_cpu(); 2158 put_cpu();
2109 if (locked)
2110 XFS_SB_UNLOCK(mp, s);
2111 return 0; 2159 return 0;
2112 2160
2113 /*
2114 * The slow path needs to be run with the SBLOCK
2115 * held so that we prevent other threads from
2116 * attempting to run this path at the same time.
2117 * this provides exclusion for the balancing code,
2118 * and exclusive fallback if the balance does not
2119 * provide enough resources to continue in an unlocked
2120 * manner.
2121 */
2122slow_path: 2161slow_path:
2123 xfs_icsb_unlock_cntr(icsbp);
2124 put_cpu(); 2162 put_cpu();
2125 2163
2126 /* need to hold superblock incase we need 2164 /*
2127 * to disable a counter */ 2165 * serialise with a mutex so we don't burn lots of cpu on
2128 if (!(flags & XFS_ICSB_SB_LOCKED)) { 2166 * the superblock lock. We still need to hold the superblock
2129 s = XFS_SB_LOCK(mp); 2167 * lock, however, when we modify the global structures.
2130 locked = 1; 2168 */
2131 flags |= XFS_ICSB_SB_LOCKED; 2169 xfs_icsb_lock(mp);
2132 } 2170
2133 if (!balance_done) { 2171 /*
2134 xfs_icsb_balance_counter(mp, field, flags); 2172 * Now running atomically.
2135 balance_done = 1; 2173 *
2174 * If the counter is enabled, someone has beaten us to rebalancing.
2175 * Drop the lock and try again in the fast path....
2176 */
2177 if (!(xfs_icsb_counter_disabled(mp, field))) {
2178 xfs_icsb_unlock(mp);
2136 goto again; 2179 goto again;
2137 } else {
2138 /*
2139 * we might not have enough on this local
2140 * cpu to allocate for a bulk request.
2141 * We need to drain this field from all CPUs
2142 * and disable the counter fastpath
2143 */
2144 xfs_icsb_disable_counter(mp, field);
2145 } 2180 }
2146 2181
2182 /*
2183 * The counter is currently disabled. Because we are
2184 * running atomically here, we know a rebalance cannot
2185 * be in progress. Hence we can go straight to operating
2186 * on the global superblock. We do not call xfs_mod_incore_sb()
2187 * here even though we need to get the SB_LOCK. Doing so
2188 * will cause us to re-enter this function and deadlock.
2189 * Hence we get the SB_LOCK ourselves and then call
2190 * xfs_mod_incore_sb_unlocked() as the unlocked path operates
2191 * directly on the global counters.
2192 */
2193 s = XFS_SB_LOCK(mp);
2147 ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd); 2194 ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
2195 XFS_SB_UNLOCK(mp, s);
2148 2196
2149 if (locked) 2197 /*
2150 XFS_SB_UNLOCK(mp, s); 2198 * Now that we've modified the global superblock, we
2199 * may be able to re-enable the distributed counters
2200 * (e.g. lots of space just got freed). After that
2201 * we are done.
2202 */
2203 if (ret != ENOSPC)
2204 xfs_icsb_balance_counter(mp, field, 0, 0);
2205 xfs_icsb_unlock(mp);
2151 return ret; 2206 return ret;
2152}
2153 2207
2154STATIC int 2208balance_counter:
2155xfs_icsb_modify_counters( 2209 xfs_icsb_unlock_cntr(icsbp);
2156 xfs_mount_t *mp, 2210 put_cpu();
2157 xfs_sb_field_t field,
2158 int delta,
2159 int rsvd)
2160{
2161 return xfs_icsb_modify_counters_int(mp, field, delta, rsvd, 0);
2162}
2163 2211
2164/* 2212 /*
2165 * Called when superblock is already locked 2213 * We may have multiple threads here if multiple per-cpu
2166 */ 2214 * counters run dry at the same time. This will mean we can
2167STATIC int 2215 * do more balances than strictly necessary but it is not
2168xfs_icsb_modify_counters_locked( 2216 * the common slowpath case.
2169 xfs_mount_t *mp, 2217 */
2170 xfs_sb_field_t field, 2218 xfs_icsb_lock(mp);
2171 int delta, 2219
2172 int rsvd) 2220 /*
2173{ 2221 * running atomically.
2174 return xfs_icsb_modify_counters_int(mp, field, delta, 2222 *
2175 rsvd, XFS_ICSB_SB_LOCKED); 2223 * This will leave the counter in the correct state for future
2224 * accesses. After the rebalance, we simply try again and our retry
2225 * will either succeed through the fast path or slow path without
2226 * another balance operation being required.
2227 */
2228 xfs_icsb_balance_counter(mp, field, 0, delta);
2229 xfs_icsb_unlock(mp);
2230 goto again;
2176} 2231}
2232
2177#endif 2233#endif
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index e5f396ff9a3d..82304b94646d 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -18,6 +18,7 @@
18#ifndef __XFS_MOUNT_H__ 18#ifndef __XFS_MOUNT_H__
19#define __XFS_MOUNT_H__ 19#define __XFS_MOUNT_H__
20 20
21
21typedef struct xfs_trans_reservations { 22typedef struct xfs_trans_reservations {
22 uint tr_write; /* extent alloc trans */ 23 uint tr_write; /* extent alloc trans */
23 uint tr_itruncate; /* truncate trans */ 24 uint tr_itruncate; /* truncate trans */
@@ -306,11 +307,13 @@ typedef struct xfs_icsb_cnts {
306#define XFS_ICSB_LAZY_COUNT (1 << 1) /* accuracy not needed */ 307#define XFS_ICSB_LAZY_COUNT (1 << 1) /* accuracy not needed */
307 308
308extern int xfs_icsb_init_counters(struct xfs_mount *); 309extern int xfs_icsb_init_counters(struct xfs_mount *);
309extern void xfs_icsb_sync_counters_lazy(struct xfs_mount *); 310extern void xfs_icsb_reinit_counters(struct xfs_mount *);
311extern void xfs_icsb_sync_counters_flags(struct xfs_mount *, int);
310 312
311#else 313#else
312#define xfs_icsb_init_counters(mp) (0) 314#define xfs_icsb_init_counters(mp) (0)
313#define xfs_icsb_sync_counters_lazy(mp) do { } while (0) 315#define xfs_icsb_reinit_counters(mp) do { } while (0)
316#define xfs_icsb_sync_counters_flags(mp, flags) do { } while (0)
314#endif 317#endif
315 318
316typedef struct xfs_mount { 319typedef struct xfs_mount {
@@ -419,6 +422,7 @@ typedef struct xfs_mount {
419 xfs_icsb_cnts_t *m_sb_cnts; /* per-cpu superblock counters */ 422 xfs_icsb_cnts_t *m_sb_cnts; /* per-cpu superblock counters */
420 unsigned long m_icsb_counters; /* disabled per-cpu counters */ 423 unsigned long m_icsb_counters; /* disabled per-cpu counters */
421 struct notifier_block m_icsb_notifier; /* hotplug cpu notifier */ 424 struct notifier_block m_icsb_notifier; /* hotplug cpu notifier */
425 struct mutex m_icsb_mutex; /* balancer sync lock */
422#endif 426#endif
423} xfs_mount_t; 427} xfs_mount_t;
424 428
@@ -563,11 +567,32 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
563} 567}
564 568
565/* 569/*
570 * Per-cpu superblock locking functions
571 */
572#ifdef HAVE_PERCPU_SB
573STATIC_INLINE void
574xfs_icsb_lock(xfs_mount_t *mp)
575{
576 mutex_lock(&mp->m_icsb_mutex);
577}
578
579STATIC_INLINE void
580xfs_icsb_unlock(xfs_mount_t *mp)
581{
582 mutex_unlock(&mp->m_icsb_mutex);
583}
584#else
585#define xfs_icsb_lock(mp)
586#define xfs_icsb_unlock(mp)
587#endif
588
589/*
566 * This structure is for use by the xfs_mod_incore_sb_batch() routine. 590 * This structure is for use by the xfs_mod_incore_sb_batch() routine.
591 * xfs_growfs can specify a few fields which are more than int limit
567 */ 592 */
568typedef struct xfs_mod_sb { 593typedef struct xfs_mod_sb {
569 xfs_sb_field_t msb_field; /* Field to modify, see below */ 594 xfs_sb_field_t msb_field; /* Field to modify, see below */
570 int msb_delta; /* Change to make to specified field */ 595 int64_t msb_delta; /* Change to make to specified field */
571} xfs_mod_sb_t; 596} xfs_mod_sb_t;
572 597
573#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock)) 598#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock))
@@ -585,17 +610,17 @@ extern int xfs_unmountfs(xfs_mount_t *, struct cred *);
585extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); 610extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
586extern int xfs_unmountfs_writesb(xfs_mount_t *); 611extern int xfs_unmountfs_writesb(xfs_mount_t *);
587extern int xfs_unmount_flush(xfs_mount_t *, int); 612extern int xfs_unmount_flush(xfs_mount_t *, int);
588extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int); 613extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int);
589extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t, 614extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t,
590 int, int); 615 int64_t, int);
591extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, 616extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
592 uint, int); 617 uint, int);
593extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); 618extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
594extern int xfs_readsb(xfs_mount_t *, int); 619extern int xfs_readsb(xfs_mount_t *, int);
595extern void xfs_freesb(xfs_mount_t *); 620extern void xfs_freesb(xfs_mount_t *);
596extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); 621extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
597extern int xfs_syncsub(xfs_mount_t *, int, int, int *); 622extern int xfs_syncsub(xfs_mount_t *, int, int *);
598extern int xfs_sync_inodes(xfs_mount_t *, int, int, int *); 623extern int xfs_sync_inodes(xfs_mount_t *, int, int *);
599extern xfs_agnumber_t xfs_initialize_perag(struct bhv_vfs *, xfs_mount_t *, 624extern xfs_agnumber_t xfs_initialize_perag(struct bhv_vfs *, xfs_mount_t *,
600 xfs_agnumber_t); 625 xfs_agnumber_t);
601extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t); 626extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t);
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index d98171deaa1c..4c6573d784cd 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -565,7 +565,7 @@ xfs_rename(
565 IHOLD(target_ip); 565 IHOLD(target_ip);
566 IHOLD(src_ip); 566 IHOLD(src_ip);
567 567
568 error = xfs_bmap_finish(&tp, &free_list, first_block, &committed); 568 error = xfs_bmap_finish(&tp, &free_list, &committed);
569 if (error) { 569 if (error) {
570 xfs_bmap_cancel(&free_list); 570 xfs_bmap_cancel(&free_list);
571 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | 571 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 880c73271c05..6fff19dc3cf9 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -147,7 +147,7 @@ xfs_growfs_rt_alloc(
147 /* 147 /*
148 * Free any blocks freed up in the transaction, then commit. 148 * Free any blocks freed up in the transaction, then commit.
149 */ 149 */
150 error = xfs_bmap_finish(&tp, &flist, firstblock, &committed); 150 error = xfs_bmap_finish(&tp, &flist, &committed);
151 if (error) 151 if (error)
152 goto error_exit; 152 goto error_exit;
153 xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 153 xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
@@ -913,57 +913,6 @@ xfs_rtcheck_alloc_range(
913} 913}
914#endif 914#endif
915 915
916#ifdef DEBUG
917/*
918 * Check whether the given block in the bitmap has the given value.
919 */
920STATIC int /* 1 for matches, 0 for not */
921xfs_rtcheck_bit(
922 xfs_mount_t *mp, /* file system mount structure */
923 xfs_trans_t *tp, /* transaction pointer */
924 xfs_rtblock_t start, /* bit (block) to check */
925 int val) /* 1 for free, 0 for allocated */
926{
927 int bit; /* bit number in the word */
928 xfs_rtblock_t block; /* bitmap block number */
929 xfs_buf_t *bp; /* buf for the block */
930 xfs_rtword_t *bufp; /* pointer into the buffer */
931 /* REFERENCED */
932 int error; /* error value */
933 xfs_rtword_t wdiff; /* difference between bit & expected */
934 int word; /* word number in the buffer */
935 xfs_rtword_t wval; /* word value from buffer */
936
937 block = XFS_BITTOBLOCK(mp, start);
938 error = xfs_rtbuf_get(mp, tp, block, 0, &bp);
939 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp);
940 word = XFS_BITTOWORD(mp, start);
941 bit = (int)(start & (XFS_NBWORD - 1));
942 wval = bufp[word];
943 xfs_trans_brelse(tp, bp);
944 wdiff = (wval ^ -val) & ((xfs_rtword_t)1 << bit);
945 return !wdiff;
946}
947#endif /* DEBUG */
948
949#if 0
950/*
951 * Check that the given extent (block range) is free already.
952 */
953STATIC int /* error */
954xfs_rtcheck_free_range(
955 xfs_mount_t *mp, /* file system mount point */
956 xfs_trans_t *tp, /* transaction pointer */
957 xfs_rtblock_t bno, /* starting block number of extent */
958 xfs_extlen_t len, /* length of extent */
959 int *stat) /* out: 1 for free, 0 for not */
960{
961 xfs_rtblock_t new; /* dummy for xfs_rtcheck_range */
962
963 return xfs_rtcheck_range(mp, tp, bno, len, 1, &new, stat);
964}
965#endif
966
967/* 916/*
968 * Check that the given range is either all allocated (val = 0) or 917 * Check that the given range is either all allocated (val = 0) or
969 * all free (val = 1). 918 * all free (val = 1).
@@ -2382,60 +2331,3 @@ xfs_rtpick_extent(
2382 *pick = b; 2331 *pick = b;
2383 return 0; 2332 return 0;
2384} 2333}
2385
2386#ifdef DEBUG
2387/*
2388 * Debug code: print out the value of a range in the bitmap.
2389 */
2390void
2391xfs_rtprint_range(
2392 xfs_mount_t *mp, /* file system mount structure */
2393 xfs_trans_t *tp, /* transaction pointer */
2394 xfs_rtblock_t start, /* starting block to print */
2395 xfs_extlen_t len) /* length to print */
2396{
2397 xfs_extlen_t i; /* block number in the extent */
2398
2399 cmn_err(CE_DEBUG, "%Ld: ", (long long)start);
2400 for (i = 0; i < len; i++)
2401 cmn_err(CE_DEBUG, "%d", xfs_rtcheck_bit(mp, tp, start + i, 1));
2402 cmn_err(CE_DEBUG, "\n");
2403}
2404
2405/*
2406 * Debug code: print the summary file.
2407 */
2408void
2409xfs_rtprint_summary(
2410 xfs_mount_t *mp, /* file system mount structure */
2411 xfs_trans_t *tp) /* transaction pointer */
2412{
2413 xfs_suminfo_t c; /* summary data */
2414 xfs_rtblock_t i; /* bitmap block number */
2415 int l; /* summary information level */
2416 int p; /* flag for printed anything */
2417 xfs_fsblock_t sb; /* summary block number */
2418 xfs_buf_t *sumbp; /* summary block buffer */
2419
2420 sumbp = NULL;
2421 for (l = 0; l < mp->m_rsumlevels; l++) {
2422 for (p = 0, i = 0; i < mp->m_sb.sb_rbmblocks; i++) {
2423 (void)xfs_rtget_summary(mp, tp, l, i, &sumbp, &sb, &c);
2424 if (c) {
2425 if (!p) {
2426 cmn_err(CE_DEBUG, "%Ld-%Ld:", 1LL << l,
2427 XFS_RTMIN((1LL << l) +
2428 ((1LL << l) - 1LL),
2429 mp->m_sb.sb_rextents));
2430 p = 1;
2431 }
2432 cmn_err(CE_DEBUG, " %Ld:%d", (long long)i, c);
2433 }
2434 }
2435 if (p)
2436 cmn_err(CE_DEBUG, "\n");
2437 }
2438 if (sumbp)
2439 xfs_trans_brelse(tp, sumbp);
2440}
2441#endif /* DEBUG */
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 0e0b4d2ec202..799c1f871263 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -134,24 +134,6 @@ xfs_rtpick_extent(
134 xfs_rtblock_t *pick); /* result rt extent */ 134 xfs_rtblock_t *pick); /* result rt extent */
135 135
136/* 136/*
137 * Debug code: print out the value of a range in the bitmap.
138 */
139void
140xfs_rtprint_range(
141 struct xfs_mount *mp, /* file system mount structure */
142 struct xfs_trans *tp, /* transaction pointer */
143 xfs_rtblock_t start, /* starting block to print */
144 xfs_extlen_t len); /* length to print */
145
146/*
147 * Debug code: print the summary file.
148 */
149void
150xfs_rtprint_summary(
151 struct xfs_mount *mp, /* file system mount structure */
152 struct xfs_trans *tp); /* transaction pointer */
153
154/*
155 * Grow the realtime area of the filesystem. 137 * Grow the realtime area of the filesystem.
156 */ 138 */
157int 139int
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index defb2febaaf5..1ea7c0ca6ae0 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -42,7 +42,6 @@
42#include "xfs_attr.h" 42#include "xfs_attr.h"
43#include "xfs_bmap.h" 43#include "xfs_bmap.h"
44#include "xfs_acl.h" 44#include "xfs_acl.h"
45#include "xfs_mac.h"
46#include "xfs_error.h" 45#include "xfs_error.h"
47#include "xfs_buf_item.h" 46#include "xfs_buf_item.h"
48#include "xfs_rw.h" 47#include "xfs_rw.h"
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index ee2721e0de4d..301ff9445b6f 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -339,7 +339,7 @@ xfs_trans_reserve(
339 */ 339 */
340 if (blocks > 0) { 340 if (blocks > 0) {
341 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, 341 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS,
342 -blocks, rsvd); 342 -((int64_t)blocks), rsvd);
343 if (error != 0) { 343 if (error != 0) {
344 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); 344 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
345 return (XFS_ERROR(ENOSPC)); 345 return (XFS_ERROR(ENOSPC));
@@ -380,7 +380,7 @@ xfs_trans_reserve(
380 */ 380 */
381 if (rtextents > 0) { 381 if (rtextents > 0) {
382 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS, 382 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS,
383 -rtextents, rsvd); 383 -((int64_t)rtextents), rsvd);
384 if (error) { 384 if (error) {
385 error = XFS_ERROR(ENOSPC); 385 error = XFS_ERROR(ENOSPC);
386 goto undo_log; 386 goto undo_log;
@@ -410,7 +410,7 @@ undo_log:
410undo_blocks: 410undo_blocks:
411 if (blocks > 0) { 411 if (blocks > 0) {
412 (void) xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, 412 (void) xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS,
413 blocks, rsvd); 413 (int64_t)blocks, rsvd);
414 tp->t_blk_res = 0; 414 tp->t_blk_res = 0;
415 } 415 }
416 416
@@ -432,7 +432,7 @@ void
432xfs_trans_mod_sb( 432xfs_trans_mod_sb(
433 xfs_trans_t *tp, 433 xfs_trans_t *tp,
434 uint field, 434 uint field,
435 long delta) 435 int64_t delta)
436{ 436{
437 437
438 switch (field) { 438 switch (field) {
@@ -663,62 +663,62 @@ xfs_trans_unreserve_and_mod_sb(
663 if (tp->t_flags & XFS_TRANS_SB_DIRTY) { 663 if (tp->t_flags & XFS_TRANS_SB_DIRTY) {
664 if (tp->t_icount_delta != 0) { 664 if (tp->t_icount_delta != 0) {
665 msbp->msb_field = XFS_SBS_ICOUNT; 665 msbp->msb_field = XFS_SBS_ICOUNT;
666 msbp->msb_delta = (int)tp->t_icount_delta; 666 msbp->msb_delta = tp->t_icount_delta;
667 msbp++; 667 msbp++;
668 } 668 }
669 if (tp->t_ifree_delta != 0) { 669 if (tp->t_ifree_delta != 0) {
670 msbp->msb_field = XFS_SBS_IFREE; 670 msbp->msb_field = XFS_SBS_IFREE;
671 msbp->msb_delta = (int)tp->t_ifree_delta; 671 msbp->msb_delta = tp->t_ifree_delta;
672 msbp++; 672 msbp++;
673 } 673 }
674 if (tp->t_fdblocks_delta != 0) { 674 if (tp->t_fdblocks_delta != 0) {
675 msbp->msb_field = XFS_SBS_FDBLOCKS; 675 msbp->msb_field = XFS_SBS_FDBLOCKS;
676 msbp->msb_delta = (int)tp->t_fdblocks_delta; 676 msbp->msb_delta = tp->t_fdblocks_delta;
677 msbp++; 677 msbp++;
678 } 678 }
679 if (tp->t_frextents_delta != 0) { 679 if (tp->t_frextents_delta != 0) {
680 msbp->msb_field = XFS_SBS_FREXTENTS; 680 msbp->msb_field = XFS_SBS_FREXTENTS;
681 msbp->msb_delta = (int)tp->t_frextents_delta; 681 msbp->msb_delta = tp->t_frextents_delta;
682 msbp++; 682 msbp++;
683 } 683 }
684 if (tp->t_dblocks_delta != 0) { 684 if (tp->t_dblocks_delta != 0) {
685 msbp->msb_field = XFS_SBS_DBLOCKS; 685 msbp->msb_field = XFS_SBS_DBLOCKS;
686 msbp->msb_delta = (int)tp->t_dblocks_delta; 686 msbp->msb_delta = tp->t_dblocks_delta;
687 msbp++; 687 msbp++;
688 } 688 }
689 if (tp->t_agcount_delta != 0) { 689 if (tp->t_agcount_delta != 0) {
690 msbp->msb_field = XFS_SBS_AGCOUNT; 690 msbp->msb_field = XFS_SBS_AGCOUNT;
691 msbp->msb_delta = (int)tp->t_agcount_delta; 691 msbp->msb_delta = tp->t_agcount_delta;
692 msbp++; 692 msbp++;
693 } 693 }
694 if (tp->t_imaxpct_delta != 0) { 694 if (tp->t_imaxpct_delta != 0) {
695 msbp->msb_field = XFS_SBS_IMAX_PCT; 695 msbp->msb_field = XFS_SBS_IMAX_PCT;
696 msbp->msb_delta = (int)tp->t_imaxpct_delta; 696 msbp->msb_delta = tp->t_imaxpct_delta;
697 msbp++; 697 msbp++;
698 } 698 }
699 if (tp->t_rextsize_delta != 0) { 699 if (tp->t_rextsize_delta != 0) {
700 msbp->msb_field = XFS_SBS_REXTSIZE; 700 msbp->msb_field = XFS_SBS_REXTSIZE;
701 msbp->msb_delta = (int)tp->t_rextsize_delta; 701 msbp->msb_delta = tp->t_rextsize_delta;
702 msbp++; 702 msbp++;
703 } 703 }
704 if (tp->t_rbmblocks_delta != 0) { 704 if (tp->t_rbmblocks_delta != 0) {
705 msbp->msb_field = XFS_SBS_RBMBLOCKS; 705 msbp->msb_field = XFS_SBS_RBMBLOCKS;
706 msbp->msb_delta = (int)tp->t_rbmblocks_delta; 706 msbp->msb_delta = tp->t_rbmblocks_delta;
707 msbp++; 707 msbp++;
708 } 708 }
709 if (tp->t_rblocks_delta != 0) { 709 if (tp->t_rblocks_delta != 0) {
710 msbp->msb_field = XFS_SBS_RBLOCKS; 710 msbp->msb_field = XFS_SBS_RBLOCKS;
711 msbp->msb_delta = (int)tp->t_rblocks_delta; 711 msbp->msb_delta = tp->t_rblocks_delta;
712 msbp++; 712 msbp++;
713 } 713 }
714 if (tp->t_rextents_delta != 0) { 714 if (tp->t_rextents_delta != 0) {
715 msbp->msb_field = XFS_SBS_REXTENTS; 715 msbp->msb_field = XFS_SBS_REXTENTS;
716 msbp->msb_delta = (int)tp->t_rextents_delta; 716 msbp->msb_delta = tp->t_rextents_delta;
717 msbp++; 717 msbp++;
718 } 718 }
719 if (tp->t_rextslog_delta != 0) { 719 if (tp->t_rextslog_delta != 0) {
720 msbp->msb_field = XFS_SBS_REXTSLOG; 720 msbp->msb_field = XFS_SBS_REXTSLOG;
721 msbp->msb_delta = (int)tp->t_rextslog_delta; 721 msbp->msb_delta = tp->t_rextslog_delta;
722 msbp++; 722 msbp++;
723 } 723 }
724 } 724 }
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index c68e00105d23..f1d7ab236726 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -39,13 +39,9 @@ typedef struct xfs_trans_header {
39/* 39/*
40 * Log item types. 40 * Log item types.
41 */ 41 */
42#define XFS_LI_5_3_BUF 0x1234 /* v1 bufs, 1-block inode buffers */
43#define XFS_LI_5_3_INODE 0x1235 /* 1-block inode buffers */
44#define XFS_LI_EFI 0x1236 42#define XFS_LI_EFI 0x1236
45#define XFS_LI_EFD 0x1237 43#define XFS_LI_EFD 0x1237
46#define XFS_LI_IUNLINK 0x1238 44#define XFS_LI_IUNLINK 0x1238
47#define XFS_LI_6_1_INODE 0x1239 /* 4K non-aligned inode bufs */
48#define XFS_LI_6_1_BUF 0x123a /* v1, 4K inode buffers */
49#define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */ 45#define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */
50#define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */ 46#define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */
51#define XFS_LI_DQUOT 0x123d 47#define XFS_LI_DQUOT 0x123d
@@ -354,25 +350,25 @@ typedef struct xfs_trans {
354 xfs_trans_callback_t t_callback; /* transaction callback */ 350 xfs_trans_callback_t t_callback; /* transaction callback */
355 void *t_callarg; /* callback arg */ 351 void *t_callarg; /* callback arg */
356 unsigned int t_flags; /* misc flags */ 352 unsigned int t_flags; /* misc flags */
357 long t_icount_delta; /* superblock icount change */ 353 int64_t t_icount_delta; /* superblock icount change */
358 long t_ifree_delta; /* superblock ifree change */ 354 int64_t t_ifree_delta; /* superblock ifree change */
359 long t_fdblocks_delta; /* superblock fdblocks chg */ 355 int64_t t_fdblocks_delta; /* superblock fdblocks chg */
360 long t_res_fdblocks_delta; /* on-disk only chg */ 356 int64_t t_res_fdblocks_delta; /* on-disk only chg */
361 long t_frextents_delta;/* superblock freextents chg*/ 357 int64_t t_frextents_delta;/* superblock freextents chg*/
362 long t_res_frextents_delta; /* on-disk only chg */ 358 int64_t t_res_frextents_delta; /* on-disk only chg */
363#ifdef DEBUG 359#ifdef DEBUG
364 long t_ag_freeblks_delta; /* debugging counter */ 360 int64_t t_ag_freeblks_delta; /* debugging counter */
365 long t_ag_flist_delta; /* debugging counter */ 361 int64_t t_ag_flist_delta; /* debugging counter */
366 long t_ag_btree_delta; /* debugging counter */ 362 int64_t t_ag_btree_delta; /* debugging counter */
367#endif 363#endif
368 long t_dblocks_delta;/* superblock dblocks change */ 364 int64_t t_dblocks_delta;/* superblock dblocks change */
369 long t_agcount_delta;/* superblock agcount change */ 365 int64_t t_agcount_delta;/* superblock agcount change */
370 long t_imaxpct_delta;/* superblock imaxpct change */ 366 int64_t t_imaxpct_delta;/* superblock imaxpct change */
371 long t_rextsize_delta;/* superblock rextsize chg */ 367 int64_t t_rextsize_delta;/* superblock rextsize chg */
372 long t_rbmblocks_delta;/* superblock rbmblocks chg */ 368 int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
373 long t_rblocks_delta;/* superblock rblocks change */ 369 int64_t t_rblocks_delta;/* superblock rblocks change */
374 long t_rextents_delta;/* superblocks rextents chg */ 370 int64_t t_rextents_delta;/* superblocks rextents chg */
375 long t_rextslog_delta;/* superblocks rextslog chg */ 371 int64_t t_rextslog_delta;/* superblocks rextslog chg */
376 unsigned int t_items_free; /* log item descs free */ 372 unsigned int t_items_free; /* log item descs free */
377 xfs_log_item_chunk_t t_items; /* first log item desc chunk */ 373 xfs_log_item_chunk_t t_items; /* first log item desc chunk */
378 xfs_trans_header_t t_header; /* header for in-log trans */ 374 xfs_trans_header_t t_header; /* header for in-log trans */
@@ -936,9 +932,9 @@ typedef struct xfs_trans {
936#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC) 932#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
937 933
938#ifdef DEBUG 934#ifdef DEBUG
939#define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (long)d) 935#define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (int64_t)d)
940#define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (long)d) 936#define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (int64_t)d)
941#define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (long)d) 937#define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (int64_t)d)
942#else 938#else
943#define xfs_trans_agblocks_delta(tp, d) 939#define xfs_trans_agblocks_delta(tp, d)
944#define xfs_trans_agflist_delta(tp, d) 940#define xfs_trans_agflist_delta(tp, d)
@@ -954,7 +950,7 @@ xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);
954xfs_trans_t *xfs_trans_dup(xfs_trans_t *); 950xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
955int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, 951int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
956 uint, uint); 952 uint, uint);
957void xfs_trans_mod_sb(xfs_trans_t *, uint, long); 953void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
958struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t, 954struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t,
959 int, uint); 955 int, uint);
960int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *, 956int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *,
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index fc39b166d403..ceb4f6e99960 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -90,7 +90,7 @@ xfs_trans_push_ail(
90 int flush_log; 90 int flush_log;
91 SPLDECL(s); 91 SPLDECL(s);
92 92
93#define XFS_TRANS_PUSH_AIL_RESTARTS 10 93#define XFS_TRANS_PUSH_AIL_RESTARTS 1000
94 94
95 AIL_LOCK(mp,s); 95 AIL_LOCK(mp,s);
96 lip = xfs_trans_first_ail(mp, &gen); 96 lip = xfs_trans_first_ail(mp, &gen);
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 62336a4cc5a4..29f72f613782 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -640,7 +640,7 @@ xfs_quiesce_fs(
640 * we can write the unmount record. 640 * we can write the unmount record.
641 */ 641 */
642 do { 642 do {
643 xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL); 643 xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, NULL);
644 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1); 644 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
645 if (!pincount) { 645 if (!pincount) {
646 delay(50); 646 delay(50);
@@ -806,7 +806,7 @@ xfs_statvfs(
806 806
807 statp->f_type = XFS_SB_MAGIC; 807 statp->f_type = XFS_SB_MAGIC;
808 808
809 xfs_icsb_sync_counters_lazy(mp); 809 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
810 s = XFS_SB_LOCK(mp); 810 s = XFS_SB_LOCK(mp);
811 statp->f_bsize = sbp->sb_blocksize; 811 statp->f_bsize = sbp->sb_blocksize;
812 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; 812 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
@@ -872,6 +872,10 @@ xfs_statvfs(
872 * this by simply making sure the log gets flushed 872 * this by simply making sure the log gets flushed
873 * if SYNC_BDFLUSH is set, and by actually writing it 873 * if SYNC_BDFLUSH is set, and by actually writing it
874 * out otherwise. 874 * out otherwise.
875 * SYNC_IOWAIT - The caller wants us to wait for all data I/O to complete
876 * before we return (including direct I/O). Forms the drain
877 * side of the write barrier needed to safely quiesce the
878 * filesystem.
875 * 879 *
876 */ 880 */
877/*ARGSUSED*/ 881/*ARGSUSED*/
@@ -883,27 +887,20 @@ xfs_sync(
883{ 887{
884 xfs_mount_t *mp = XFS_BHVTOM(bdp); 888 xfs_mount_t *mp = XFS_BHVTOM(bdp);
885 889
886 if (unlikely(flags == SYNC_QUIESCE)) 890 return xfs_syncsub(mp, flags, NULL);
887 return xfs_quiesce_fs(mp);
888 else
889 return xfs_syncsub(mp, flags, 0, NULL);
890} 891}
891 892
892/* 893/*
893 * xfs sync routine for internal use 894 * xfs sync routine for internal use
894 * 895 *
895 * This routine supports all of the flags defined for the generic vfs_sync 896 * This routine supports all of the flags defined for the generic vfs_sync
896 * interface as explained above under xfs_sync. In the interests of not 897 * interface as explained above under xfs_sync.
897 * changing interfaces within the 6.5 family, additional internally-
898 * required functions are specified within a separate xflags parameter,
899 * only available by calling this routine.
900 * 898 *
901 */ 899 */
902int 900int
903xfs_sync_inodes( 901xfs_sync_inodes(
904 xfs_mount_t *mp, 902 xfs_mount_t *mp,
905 int flags, 903 int flags,
906 int xflags,
907 int *bypassed) 904 int *bypassed)
908{ 905{
909 xfs_inode_t *ip = NULL; 906 xfs_inode_t *ip = NULL;
@@ -1176,6 +1173,13 @@ xfs_sync_inodes(
1176 } 1173 }
1177 1174
1178 } 1175 }
1176 /*
1177 * When freezing, we need to wait ensure all I/O (including direct
1178 * I/O) is complete to ensure no further data modification can take
1179 * place after this point
1180 */
1181 if (flags & SYNC_IOWAIT)
1182 vn_iowait(vp);
1179 1183
1180 if (flags & SYNC_BDFLUSH) { 1184 if (flags & SYNC_BDFLUSH) {
1181 if ((flags & SYNC_ATTR) && 1185 if ((flags & SYNC_ATTR) &&
@@ -1412,17 +1416,13 @@ xfs_sync_inodes(
1412 * xfs sync routine for internal use 1416 * xfs sync routine for internal use
1413 * 1417 *
1414 * This routine supports all of the flags defined for the generic vfs_sync 1418 * This routine supports all of the flags defined for the generic vfs_sync
1415 * interface as explained above under xfs_sync. In the interests of not 1419 * interface as explained above under xfs_sync.
1416 * changing interfaces within the 6.5 family, additional internally-
1417 * required functions are specified within a separate xflags parameter,
1418 * only available by calling this routine.
1419 * 1420 *
1420 */ 1421 */
1421int 1422int
1422xfs_syncsub( 1423xfs_syncsub(
1423 xfs_mount_t *mp, 1424 xfs_mount_t *mp,
1424 int flags, 1425 int flags,
1425 int xflags,
1426 int *bypassed) 1426 int *bypassed)
1427{ 1427{
1428 int error = 0; 1428 int error = 0;
@@ -1444,7 +1444,7 @@ xfs_syncsub(
1444 if (flags & SYNC_BDFLUSH) 1444 if (flags & SYNC_BDFLUSH)
1445 xfs_finish_reclaim_all(mp, 1); 1445 xfs_finish_reclaim_all(mp, 1);
1446 else 1446 else
1447 error = xfs_sync_inodes(mp, flags, xflags, bypassed); 1447 error = xfs_sync_inodes(mp, flags, bypassed);
1448 } 1448 }
1449 1449
1450 /* 1450 /*
@@ -1958,15 +1958,26 @@ xfs_showargs(
1958 return 0; 1958 return 0;
1959} 1959}
1960 1960
1961/*
1962 * Second stage of a freeze. The data is already frozen, now we have to take
1963 * care of the metadata. New transactions are already blocked, so we need to
1964 * wait for any remaining transactions to drain out before proceding.
1965 */
1961STATIC void 1966STATIC void
1962xfs_freeze( 1967xfs_freeze(
1963 bhv_desc_t *bdp) 1968 bhv_desc_t *bdp)
1964{ 1969{
1965 xfs_mount_t *mp = XFS_BHVTOM(bdp); 1970 xfs_mount_t *mp = XFS_BHVTOM(bdp);
1966 1971
1972 /* wait for all modifications to complete */
1967 while (atomic_read(&mp->m_active_trans) > 0) 1973 while (atomic_read(&mp->m_active_trans) > 0)
1968 delay(100); 1974 delay(100);
1969 1975
1976 /* flush inodes and push all remaining buffers out to disk */
1977 xfs_quiesce_fs(mp);
1978
1979 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0);
1980
1970 /* Push the superblock and write an unmount record */ 1981 /* Push the superblock and write an unmount record */
1971 xfs_log_unmount_write(mp); 1982 xfs_log_unmount_write(mp);
1972 xfs_unmountfs_writesb(mp); 1983 xfs_unmountfs_writesb(mp);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index bda774a04b8f..52c41714ec54 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -51,7 +51,6 @@
51#include "xfs_refcache.h" 51#include "xfs_refcache.h"
52#include "xfs_trans_space.h" 52#include "xfs_trans_space.h"
53#include "xfs_log_priv.h" 53#include "xfs_log_priv.h"
54#include "xfs_mac.h"
55 54
56STATIC int 55STATIC int
57xfs_open( 56xfs_open(
@@ -1381,7 +1380,7 @@ xfs_inactive_symlink_rmt(
1381 /* 1380 /*
1382 * Commit the first transaction. This logs the EFI and the inode. 1381 * Commit the first transaction. This logs the EFI and the inode.
1383 */ 1382 */
1384 if ((error = xfs_bmap_finish(&tp, &free_list, first_block, &committed))) 1383 if ((error = xfs_bmap_finish(&tp, &free_list, &committed)))
1385 goto error1; 1384 goto error1;
1386 /* 1385 /*
1387 * The transaction must have been committed, since there were 1386 * The transaction must have been committed, since there were
@@ -1790,8 +1789,7 @@ xfs_inactive(
1790 * Just ignore errors at this point. There is 1789 * Just ignore errors at this point. There is
1791 * nothing we can do except to try to keep going. 1790 * nothing we can do except to try to keep going.
1792 */ 1791 */
1793 (void) xfs_bmap_finish(&tp, &free_list, first_block, 1792 (void) xfs_bmap_finish(&tp, &free_list, &committed);
1794 &committed);
1795 (void) xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 1793 (void) xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
1796 } 1794 }
1797 /* 1795 /*
@@ -2022,7 +2020,7 @@ xfs_create(
2022 IHOLD(ip); 2020 IHOLD(ip);
2023 vp = XFS_ITOV(ip); 2021 vp = XFS_ITOV(ip);
2024 2022
2025 error = xfs_bmap_finish(&tp, &free_list, first_block, &committed); 2023 error = xfs_bmap_finish(&tp, &free_list, &committed);
2026 if (error) { 2024 if (error) {
2027 xfs_bmap_cancel(&free_list); 2025 xfs_bmap_cancel(&free_list);
2028 goto abort_rele; 2026 goto abort_rele;
@@ -2507,7 +2505,7 @@ xfs_remove(
2507 xfs_trans_set_sync(tp); 2505 xfs_trans_set_sync(tp);
2508 } 2506 }
2509 2507
2510 error = xfs_bmap_finish(&tp, &free_list, first_block, &committed); 2508 error = xfs_bmap_finish(&tp, &free_list, &committed);
2511 if (error) { 2509 if (error) {
2512 REMOVE_DEBUG_TRACE(__LINE__); 2510 REMOVE_DEBUG_TRACE(__LINE__);
2513 goto error_rele; 2511 goto error_rele;
@@ -2715,7 +2713,7 @@ xfs_link(
2715 xfs_trans_set_sync(tp); 2713 xfs_trans_set_sync(tp);
2716 } 2714 }
2717 2715
2718 error = xfs_bmap_finish (&tp, &free_list, first_block, &committed); 2716 error = xfs_bmap_finish (&tp, &free_list, &committed);
2719 if (error) { 2717 if (error) {
2720 xfs_bmap_cancel(&free_list); 2718 xfs_bmap_cancel(&free_list);
2721 goto abort_return; 2719 goto abort_return;
@@ -2932,7 +2930,7 @@ xfs_mkdir(
2932 xfs_trans_set_sync(tp); 2930 xfs_trans_set_sync(tp);
2933 } 2931 }
2934 2932
2935 error = xfs_bmap_finish(&tp, &free_list, first_block, &committed); 2933 error = xfs_bmap_finish(&tp, &free_list, &committed);
2936 if (error) { 2934 if (error) {
2937 IRELE(cdp); 2935 IRELE(cdp);
2938 goto error2; 2936 goto error2;
@@ -3183,7 +3181,7 @@ xfs_rmdir(
3183 xfs_trans_set_sync(tp); 3181 xfs_trans_set_sync(tp);
3184 } 3182 }
3185 3183
3186 error = xfs_bmap_finish (&tp, &free_list, first_block, &committed); 3184 error = xfs_bmap_finish (&tp, &free_list, &committed);
3187 if (error) { 3185 if (error) {
3188 xfs_bmap_cancel(&free_list); 3186 xfs_bmap_cancel(&free_list);
3189 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | 3187 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
@@ -3533,7 +3531,7 @@ xfs_symlink(
3533 */ 3531 */
3534 IHOLD(ip); 3532 IHOLD(ip);
3535 3533
3536 error = xfs_bmap_finish(&tp, &free_list, first_block, &committed); 3534 error = xfs_bmap_finish(&tp, &free_list, &committed);
3537 if (error) { 3535 if (error) {
3538 goto error2; 3536 goto error2;
3539 } 3537 }
@@ -4145,7 +4143,7 @@ retry:
4145 /* 4143 /*
4146 * Complete the transaction 4144 * Complete the transaction
4147 */ 4145 */
4148 error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed); 4146 error = xfs_bmap_finish(&tp, &free_list, &committed);
4149 if (error) { 4147 if (error) {
4150 goto error0; 4148 goto error0;
4151 } 4149 }
@@ -4452,7 +4450,7 @@ xfs_free_file_space(
4452 /* 4450 /*
4453 * complete the transaction 4451 * complete the transaction
4454 */ 4452 */
4455 error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed); 4453 error = xfs_bmap_finish(&tp, &free_list, &committed);
4456 if (error) { 4454 if (error) {
4457 goto error0; 4455 goto error0;
4458 } 4456 }