aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
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:49 -0400
commit26af655233dd486659235f3049959d2f7dafc5a1 (patch)
tree590b4976871582d6cad34880705a9a4021e204f5 /fs/xfs
parentebad861b5702c3e2332a3e906978f47144d22f70 (diff)
xfs: kill XBF_FS_MANAGED buffers
Filesystem level managed buffers are buffers that have their lifecycle controlled by the filesystem layer, not the buffer cache. We currently cache these buffers, which makes cleanup and cache walking somewhat troublesome. Convert the fs managed buffers to uncached buffers obtained by via xfs_buf_get_uncached(), and remove the XBF_FS_MANAGED special cases from the buffer cache. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c20
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h4
-rw-r--r--fs/xfs/xfs_mount.c55
3 files changed, 20 insertions, 59 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d6928970097f..975d6589394a 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -826,8 +826,6 @@ xfs_buf_rele(
826 atomic_inc(&bp->b_hold); 826 atomic_inc(&bp->b_hold);
827 spin_unlock(&hash->bh_lock); 827 spin_unlock(&hash->bh_lock);
828 (*(bp->b_relse)) (bp); 828 (*(bp->b_relse)) (bp);
829 } else if (bp->b_flags & XBF_FS_MANAGED) {
830 spin_unlock(&hash->bh_lock);
831 } else { 829 } else {
832 ASSERT(!(bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q))); 830 ASSERT(!(bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)));
833 list_del_init(&bp->b_hash_list); 831 list_del_init(&bp->b_hash_list);
@@ -1433,26 +1431,16 @@ void
1433xfs_wait_buftarg( 1431xfs_wait_buftarg(
1434 xfs_buftarg_t *btp) 1432 xfs_buftarg_t *btp)
1435{ 1433{
1436 xfs_buf_t *bp, *n;
1437 xfs_bufhash_t *hash; 1434 xfs_bufhash_t *hash;
1438 uint i; 1435 uint i;
1439 1436
1440 for (i = 0; i < (1 << btp->bt_hashshift); i++) { 1437 for (i = 0; i < (1 << btp->bt_hashshift); i++) {
1441 hash = &btp->bt_hash[i]; 1438 hash = &btp->bt_hash[i];
1442again:
1443 spin_lock(&hash->bh_lock); 1439 spin_lock(&hash->bh_lock);
1444 list_for_each_entry_safe(bp, n, &hash->bh_list, b_hash_list) { 1440 while (!list_empty(&hash->bh_list)) {
1445 ASSERT(btp == bp->b_target); 1441 spin_unlock(&hash->bh_lock);
1446 if (!(bp->b_flags & XBF_FS_MANAGED)) { 1442 delay(100);
1447 spin_unlock(&hash->bh_lock); 1443 spin_lock(&hash->bh_lock);
1448 /*
1449 * Catch superblock reference count leaks
1450 * immediately
1451 */
1452 BUG_ON(bp->b_bn == 0);
1453 delay(100);
1454 goto again;
1455 }
1456 } 1444 }
1457 spin_unlock(&hash->bh_lock); 1445 spin_unlock(&hash->bh_lock);
1458 } 1446 }
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index def2cea2b4d6..1f109cee136c 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -51,7 +51,6 @@ typedef enum {
51#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ 51#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */
52#define XBF_DELWRI (1 << 6) /* buffer has dirty pages */ 52#define XBF_DELWRI (1 << 6) /* buffer has dirty pages */
53#define XBF_STALE (1 << 7) /* buffer has been staled, do not find it */ 53#define XBF_STALE (1 << 7) /* buffer has been staled, do not find it */
54#define XBF_FS_MANAGED (1 << 8) /* filesystem controls freeing memory */
55#define XBF_ORDERED (1 << 11)/* use ordered writes */ 54#define XBF_ORDERED (1 << 11)/* use ordered writes */
56#define XBF_READ_AHEAD (1 << 12)/* asynchronous read-ahead */ 55#define XBF_READ_AHEAD (1 << 12)/* asynchronous read-ahead */
57#define XBF_LOG_BUFFER (1 << 13)/* this is a buffer used for the log */ 56#define XBF_LOG_BUFFER (1 << 13)/* this is a buffer used for the log */
@@ -104,7 +103,6 @@ typedef unsigned int xfs_buf_flags_t;
104 { XBF_DONE, "DONE" }, \ 103 { XBF_DONE, "DONE" }, \
105 { XBF_DELWRI, "DELWRI" }, \ 104 { XBF_DELWRI, "DELWRI" }, \
106 { XBF_STALE, "STALE" }, \ 105 { XBF_STALE, "STALE" }, \
107 { XBF_FS_MANAGED, "FS_MANAGED" }, \
108 { XBF_ORDERED, "ORDERED" }, \ 106 { XBF_ORDERED, "ORDERED" }, \
109 { XBF_READ_AHEAD, "READ_AHEAD" }, \ 107 { XBF_READ_AHEAD, "READ_AHEAD" }, \
110 { XBF_LOCK, "LOCK" }, /* should never be set */\ 108 { XBF_LOCK, "LOCK" }, /* should never be set */\
@@ -279,8 +277,6 @@ extern void xfs_buf_terminate(void);
279 XFS_BUF_DONE(bp); \ 277 XFS_BUF_DONE(bp); \
280 } while (0) 278 } while (0)
281 279
282#define XFS_BUF_UNMANAGE(bp) ((bp)->b_flags &= ~XBF_FS_MANAGED)
283
284#define XFS_BUF_DELAYWRITE(bp) ((bp)->b_flags |= XBF_DELWRI) 280#define XFS_BUF_DELAYWRITE(bp) ((bp)->b_flags |= XBF_DELWRI)
285#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp) 281#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp)
286#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) 282#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 14fc6e9e1816..fbca293326e5 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -646,7 +646,6 @@ int
646xfs_readsb(xfs_mount_t *mp, int flags) 646xfs_readsb(xfs_mount_t *mp, int flags)
647{ 647{
648 unsigned int sector_size; 648 unsigned int sector_size;
649 unsigned int extra_flags;
650 xfs_buf_t *bp; 649 xfs_buf_t *bp;
651 int error; 650 int error;
652 651
@@ -659,28 +658,24 @@ xfs_readsb(xfs_mount_t *mp, int flags)
659 * access to the superblock. 658 * access to the superblock.
660 */ 659 */
661 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp); 660 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
662 extra_flags = XBF_LOCK | XBF_FS_MANAGED | XBF_MAPPED;
663 661
664 bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR, BTOBB(sector_size), 662reread:
665 extra_flags); 663 bp = xfs_buf_read_uncached(mp, mp->m_ddev_targp,
666 if (!bp || XFS_BUF_ISERROR(bp)) { 664 XFS_SB_DADDR, sector_size, 0);
667 xfs_fs_mount_cmn_err(flags, "SB read failed"); 665 if (!bp) {
668 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM; 666 xfs_fs_mount_cmn_err(flags, "SB buffer read failed");
669 goto fail; 667 return EIO;
670 } 668 }
671 ASSERT(XFS_BUF_ISBUSY(bp));
672 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
673 669
674 /* 670 /*
675 * Initialize the mount structure from the superblock. 671 * Initialize the mount structure from the superblock.
676 * But first do some basic consistency checking. 672 * But first do some basic consistency checking.
677 */ 673 */
678 xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); 674 xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp));
679
680 error = xfs_mount_validate_sb(mp, &(mp->m_sb), flags); 675 error = xfs_mount_validate_sb(mp, &(mp->m_sb), flags);
681 if (error) { 676 if (error) {
682 xfs_fs_mount_cmn_err(flags, "SB validate failed"); 677 xfs_fs_mount_cmn_err(flags, "SB validate failed");
683 goto fail; 678 goto release_buf;
684 } 679 }
685 680
686 /* 681 /*
@@ -691,7 +686,7 @@ xfs_readsb(xfs_mount_t *mp, int flags)
691 "device supports only %u byte sectors (not %u)", 686 "device supports only %u byte sectors (not %u)",
692 sector_size, mp->m_sb.sb_sectsize); 687 sector_size, mp->m_sb.sb_sectsize);
693 error = ENOSYS; 688 error = ENOSYS;
694 goto fail; 689 goto release_buf;
695 } 690 }
696 691
697 /* 692 /*
@@ -699,33 +694,20 @@ xfs_readsb(xfs_mount_t *mp, int flags)
699 * re-read the superblock so the buffer is correctly sized. 694 * re-read the superblock so the buffer is correctly sized.
700 */ 695 */
701 if (sector_size < mp->m_sb.sb_sectsize) { 696 if (sector_size < mp->m_sb.sb_sectsize) {
702 XFS_BUF_UNMANAGE(bp);
703 xfs_buf_relse(bp); 697 xfs_buf_relse(bp);
704 sector_size = mp->m_sb.sb_sectsize; 698 sector_size = mp->m_sb.sb_sectsize;
705 bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR, 699 goto reread;
706 BTOBB(sector_size), extra_flags);
707 if (!bp || XFS_BUF_ISERROR(bp)) {
708 xfs_fs_mount_cmn_err(flags, "SB re-read failed");
709 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
710 goto fail;
711 }
712 ASSERT(XFS_BUF_ISBUSY(bp));
713 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
714 } 700 }
715 701
716 /* Initialize per-cpu counters */ 702 /* Initialize per-cpu counters */
717 xfs_icsb_reinit_counters(mp); 703 xfs_icsb_reinit_counters(mp);
718 704
719 mp->m_sb_bp = bp; 705 mp->m_sb_bp = bp;
720 xfs_buf_relse(bp); 706 xfs_buf_unlock(bp);
721 ASSERT(XFS_BUF_VALUSEMA(bp) > 0);
722 return 0; 707 return 0;
723 708
724 fail: 709release_buf:
725 if (bp) { 710 xfs_buf_relse(bp);
726 XFS_BUF_UNMANAGE(bp);
727 xfs_buf_relse(bp);
728 }
729 return error; 711 return error;
730} 712}
731 713
@@ -2005,18 +1987,13 @@ xfs_getsb(
2005 */ 1987 */
2006void 1988void
2007xfs_freesb( 1989xfs_freesb(
2008 xfs_mount_t *mp) 1990 struct xfs_mount *mp)
2009{ 1991{
2010 xfs_buf_t *bp; 1992 struct xfs_buf *bp = mp->m_sb_bp;
2011 1993
2012 /* 1994 xfs_buf_lock(bp);
2013 * Use xfs_getsb() so that the buffer will be locked
2014 * when we call xfs_buf_relse().
2015 */
2016 bp = xfs_getsb(mp, 0);
2017 XFS_BUF_UNMANAGE(bp);
2018 xfs_buf_relse(bp);
2019 mp->m_sb_bp = NULL; 1995 mp->m_sb_bp = NULL;
1996 xfs_buf_relse(bp);
2020} 1997}
2021 1998
2022/* 1999/*