aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-09-21 20:47:20 -0400
committerAlex Elder <aelder@sgi.com>2010-10-18 16:07:48 -0400
commitebad861b5702c3e2332a3e906978f47144d22f70 (patch)
tree7b4502277c46d26d1d26258d05596b58ab6b868a
parent5adc94c247c3779782c7b0b8b5e28cf50596eb37 (diff)
xfs: store xfs_mount in the buftarg instead of in the xfs_buf
Each buffer contains both a buftarg pointer and a mount pointer. If we add a mount pointer into the buftarg, we can avoid needing the b_mount field in every buffer and grab it from the buftarg when needed instead. This shrinks the xfs_buf by 8 bytes. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com>
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c9
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h5
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c8
-rw-r--r--fs/xfs/xfs_buf_item.c3
-rw-r--r--fs/xfs/xfs_log_recover.c16
5 files changed, 20 insertions, 21 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 22c7bff77ad2..d6928970097f 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -894,7 +894,7 @@ xfs_buf_lock(
894 trace_xfs_buf_lock(bp, _RET_IP_); 894 trace_xfs_buf_lock(bp, _RET_IP_);
895 895
896 if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) 896 if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE))
897 xfs_log_force(bp->b_mount, 0); 897 xfs_log_force(bp->b_target->bt_mount, 0);
898 if (atomic_read(&bp->b_io_remaining)) 898 if (atomic_read(&bp->b_io_remaining))
899 blk_run_address_space(bp->b_target->bt_mapping); 899 blk_run_address_space(bp->b_target->bt_mapping);
900 down(&bp->b_sema); 900 down(&bp->b_sema);
@@ -1017,7 +1017,6 @@ xfs_bwrite(
1017{ 1017{
1018 int error; 1018 int error;
1019 1019
1020 bp->b_mount = mp;
1021 bp->b_flags |= XBF_WRITE; 1020 bp->b_flags |= XBF_WRITE;
1022 bp->b_flags &= ~(XBF_ASYNC | XBF_READ); 1021 bp->b_flags &= ~(XBF_ASYNC | XBF_READ);
1023 1022
@@ -1038,8 +1037,6 @@ xfs_bdwrite(
1038{ 1037{
1039 trace_xfs_buf_bdwrite(bp, _RET_IP_); 1038 trace_xfs_buf_bdwrite(bp, _RET_IP_);
1040 1039
1041 bp->b_mount = mp;
1042
1043 bp->b_flags &= ~XBF_READ; 1040 bp->b_flags &= ~XBF_READ;
1044 bp->b_flags |= (XBF_DELWRI | XBF_ASYNC); 1041 bp->b_flags |= (XBF_DELWRI | XBF_ASYNC);
1045 1042
@@ -1128,7 +1125,7 @@ int
1128xfs_bdstrat_cb( 1125xfs_bdstrat_cb(
1129 struct xfs_buf *bp) 1126 struct xfs_buf *bp)
1130{ 1127{
1131 if (XFS_FORCED_SHUTDOWN(bp->b_mount)) { 1128 if (XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) {
1132 trace_xfs_bdstrat_shut(bp, _RET_IP_); 1129 trace_xfs_bdstrat_shut(bp, _RET_IP_);
1133 /* 1130 /*
1134 * Metadata write that didn't get logged but 1131 * Metadata write that didn't get logged but
@@ -1644,6 +1641,7 @@ out_error:
1644 1641
1645xfs_buftarg_t * 1642xfs_buftarg_t *
1646xfs_alloc_buftarg( 1643xfs_alloc_buftarg(
1644 struct xfs_mount *mp,
1647 struct block_device *bdev, 1645 struct block_device *bdev,
1648 int external, 1646 int external,
1649 const char *fsname) 1647 const char *fsname)
@@ -1652,6 +1650,7 @@ xfs_alloc_buftarg(
1652 1650
1653 btp = kmem_zalloc(sizeof(*btp), KM_SLEEP); 1651 btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
1654 1652
1653 btp->bt_mount = mp;
1655 btp->bt_dev = bdev->bd_dev; 1654 btp->bt_dev = bdev->bd_dev;
1656 btp->bt_bdev = bdev; 1655 btp->bt_bdev = bdev;
1657 if (xfs_setsize_buftarg_early(btp, bdev)) 1656 if (xfs_setsize_buftarg_early(btp, bdev))
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 57eedc750ee6..def2cea2b4d6 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -132,6 +132,7 @@ typedef struct xfs_buftarg {
132 dev_t bt_dev; 132 dev_t bt_dev;
133 struct block_device *bt_bdev; 133 struct block_device *bt_bdev;
134 struct address_space *bt_mapping; 134 struct address_space *bt_mapping;
135 struct xfs_mount *bt_mount;
135 unsigned int bt_bsize; 136 unsigned int bt_bsize;
136 unsigned int bt_sshift; 137 unsigned int bt_sshift;
137 size_t bt_smask; 138 size_t bt_smask;
@@ -189,7 +190,6 @@ typedef struct xfs_buf {
189 struct completion b_iowait; /* queue for I/O waiters */ 190 struct completion b_iowait; /* queue for I/O waiters */
190 void *b_fspriv; 191 void *b_fspriv;
191 void *b_fspriv2; 192 void *b_fspriv2;
192 struct xfs_mount *b_mount;
193 unsigned short b_error; /* error code on I/O */ 193 unsigned short b_error; /* error code on I/O */
194 unsigned int b_page_count; /* size of page array */ 194 unsigned int b_page_count; /* size of page array */
195 unsigned int b_offset; /* page offset in first page */ 195 unsigned int b_offset; /* page offset in first page */
@@ -377,7 +377,8 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
377/* 377/*
378 * Handling of buftargs. 378 * Handling of buftargs.
379 */ 379 */
380extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *, int, const char *); 380extern xfs_buftarg_t *xfs_alloc_buftarg(struct xfs_mount *,
381 struct block_device *, int, const char *);
381extern void xfs_free_buftarg(struct xfs_mount *, struct xfs_buftarg *); 382extern void xfs_free_buftarg(struct xfs_mount *, struct xfs_buftarg *);
382extern void xfs_wait_buftarg(xfs_buftarg_t *); 383extern void xfs_wait_buftarg(xfs_buftarg_t *);
383extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int); 384extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 83154c0a3175..4759be4daa26 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -758,18 +758,20 @@ xfs_open_devices(
758 * Setup xfs_mount buffer target pointers 758 * Setup xfs_mount buffer target pointers
759 */ 759 */
760 error = ENOMEM; 760 error = ENOMEM;
761 mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0, mp->m_fsname); 761 mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev, 0, mp->m_fsname);
762 if (!mp->m_ddev_targp) 762 if (!mp->m_ddev_targp)
763 goto out_close_rtdev; 763 goto out_close_rtdev;
764 764
765 if (rtdev) { 765 if (rtdev) {
766 mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1, mp->m_fsname); 766 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev, 1,
767 mp->m_fsname);
767 if (!mp->m_rtdev_targp) 768 if (!mp->m_rtdev_targp)
768 goto out_free_ddev_targ; 769 goto out_free_ddev_targ;
769 } 770 }
770 771
771 if (logdev && logdev != ddev) { 772 if (logdev && logdev != ddev) {
772 mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1, mp->m_fsname); 773 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev, 1,
774 mp->m_fsname);
773 if (!mp->m_logdev_targp) 775 if (!mp->m_logdev_targp)
774 goto out_free_rtdev_targ; 776 goto out_free_rtdev_targ;
775 } else { 777 } else {
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 1b09d7a280df..ee7557611b6e 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -692,8 +692,7 @@ xfs_buf_item_init(
692 * the first. If we do already have one, there is 692 * the first. If we do already have one, there is
693 * nothing to do here so return. 693 * nothing to do here so return.
694 */ 694 */
695 if (bp->b_mount != mp) 695 ASSERT(bp->b_target->bt_mount == mp);
696 bp->b_mount = mp;
697 if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) { 696 if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
698 lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *); 697 lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
699 if (lip->li_type == XFS_LI_BUF) { 698 if (lip->li_type == XFS_LI_BUF) {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 3d887542b037..351d71117f16 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -322,10 +322,11 @@ xlog_recover_iodone(
322 * this during recovery. One strike! 322 * this during recovery. One strike!
323 */ 323 */
324 xfs_ioerror_alert("xlog_recover_iodone", 324 xfs_ioerror_alert("xlog_recover_iodone",
325 bp->b_mount, bp, XFS_BUF_ADDR(bp)); 325 bp->b_target->bt_mount, bp,
326 xfs_force_shutdown(bp->b_mount, SHUTDOWN_META_IO_ERROR); 326 XFS_BUF_ADDR(bp));
327 xfs_force_shutdown(bp->b_target->bt_mount,
328 SHUTDOWN_META_IO_ERROR);
327 } 329 }
328 bp->b_mount = NULL;
329 XFS_BUF_CLR_IODONE_FUNC(bp); 330 XFS_BUF_CLR_IODONE_FUNC(bp);
330 xfs_biodone(bp); 331 xfs_biodone(bp);
331} 332}
@@ -2276,8 +2277,7 @@ xlog_recover_do_buffer_trans(
2276 XFS_BUF_STALE(bp); 2277 XFS_BUF_STALE(bp);
2277 error = xfs_bwrite(mp, bp); 2278 error = xfs_bwrite(mp, bp);
2278 } else { 2279 } else {
2279 ASSERT(bp->b_mount == NULL || bp->b_mount == mp); 2280 ASSERT(bp->b_target->bt_mount == mp);
2280 bp->b_mount = mp;
2281 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); 2281 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
2282 xfs_bdwrite(mp, bp); 2282 xfs_bdwrite(mp, bp);
2283 } 2283 }
@@ -2541,8 +2541,7 @@ xlog_recover_do_inode_trans(
2541 } 2541 }
2542 2542
2543write_inode_buffer: 2543write_inode_buffer:
2544 ASSERT(bp->b_mount == NULL || bp->b_mount == mp); 2544 ASSERT(bp->b_target->bt_mount == mp);
2545 bp->b_mount = mp;
2546 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); 2545 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
2547 xfs_bdwrite(mp, bp); 2546 xfs_bdwrite(mp, bp);
2548error: 2547error:
@@ -2679,8 +2678,7 @@ xlog_recover_do_dquot_trans(
2679 memcpy(ddq, recddq, item->ri_buf[1].i_len); 2678 memcpy(ddq, recddq, item->ri_buf[1].i_len);
2680 2679
2681 ASSERT(dq_f->qlf_size == 2); 2680 ASSERT(dq_f->qlf_size == 2);
2682 ASSERT(bp->b_mount == NULL || bp->b_mount == mp); 2681 ASSERT(bp->b_target->bt_mount == mp);
2683 bp->b_mount = mp;
2684 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); 2682 XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
2685 xfs_bdwrite(mp, bp); 2683 xfs_bdwrite(mp, bp);
2686 2684