xfs: More xfs_buf cleanups
cover xfs: More xfs_buf cleanups
These 3 patches sit on top of my recent series titled:
[PATCH 0/8] xfs: clean up unit usage in xfs_buf V2
These patches remove bits of the API that are effectively the default behaviour used by everything or are redundant. This just makes API usage simpler and gives it a smaller footprint to modify in future.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/3 xfs: kill xfs_read_buf()
From: Dave Chinner <[email protected]>
xfs_read_buf() is effectively the same as xfs_trans_read_buf() when called outside a transaction context. The error handling is slightly different in that xfs_read_buf stales the errored buffer it gets back, but there is probably good reason for xfs_trans_read_buf() for doing this.
Hence update xfs_trans_read_buf() to the same error handling as xfs_read_buf(), and convert all the callers of xfs_read_buf() to use the former function. We can then remove xfs_read_buf().
--- fs/xfs/xfs_attr.c | 4 +- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_log_recover.c | 11 +++------ fs/xfs/xfs_rw.c | 50 ---------------------------------------------- fs/xfs/xfs_rw.h | 3 -- fs/xfs/xfs_trans_buf.c | 4 +++ 6 files changed, 11 insertions(+), 63 deletions(-)
fs/xfs/xfs_attr.c +2 -2
@@ -1987,8 +1987,8 @@ xfs_attr_rmtval_get(xfs_da_args_t *args) (map[i].br_startblock != HOLESTARTBLOCK)); dblkno =XFS_FSB_TO_DADDR (mp, map[i].br_startblock); blkcnt =XFS_FSB_TO_BB (mp, map[i].br_blockcount); - error =xfs_read_buf (mp, mp->m_ddev_targp, dblkno, - blkcnt,XBF_DONT_BLOCK , &bp); + error =xfs_trans_read_buf (mp,NULL , mp->m_ddev_targp, + dblkno, blkcnt,0 , &bp);if (error)return (error);
fs/xfs/xfs_fsops.c +1 -1
@@ -402,7 +402,7 @@ xfs_growfs_data_private(/* update secondary superblocks. */ for (agno =1 ; agno < nagcount; agno++) { - error =xfs_read_buf (mp, mp->m_ddev_targp, + error =xfs_trans_read_buf (mp,NULL , mp->m_ddev_targp,XFS_AGB_TO_DADDR (mp, agno,XFS_SB_BLOCK (mp)),XFS_FSS_TO_BB (mp,1 ),0 , &bp);if (error) {
fs/xfs/xfs_log_recover.c +4 -7
@@ -2535,14 +2535,11 @@ xlog_recover_dquot_pass2(return XFS_ERROR (EIO );ASSERT (dq_f->qlf_len ==1 ); - error =xfs_read_buf (mp, mp->m_ddev_targp, - dq_f->qlf_blkno, -XFS_FSB_TO_BB (mp, dq_f->qlf_len), -0 , &bp); -if (error) { -xfs_buf_ioerror_alert (bp,"xlog_recover_do..(read#3)" ); + error =xfs_trans_read_buf (mp,NULL , mp->m_ddev_targp, dq_f->qlf_blkno, +XFS_FSB_TO_BB (mp, dq_f->qlf_len),0 , &bp); +if (error)return error; - } +ASSERT (bp); ddq = (xfs_disk_dquot_t *)xfs_buf_offset (bp, dq_f->qlf_boffset);
fs/xfs/xfs_rw.c +0 -50
56 lines not on this page · raw message
fs/xfs/xfs_rw.h +0 -3
@@ -39,9 +39,6 @@ xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)/* * Prototypes for functions in xfs_rw.c. */ -extern int xfs_read_buf (struct xfs_mount *mp,xfs_buftarg_t *btp, -xfs_daddr_t blkno,int len,uint flags, -struct xfs_buf **bpp);extern xfs_extlen_t xfs_get_extsz_hint (struct xfs_inode *ip);#endif /* __XFS_RW_H__ */
fs/xfs/xfs_trans_buf.c +4 -0
@@ -274,6 +274,8 @@ xfs_trans_read_buf(xfs_buf_log_item_t *bip;int error; + *bpp =NULL ; +if (flags ==0 ) flags =XBF_MAPPED ;
@@ -289,6 +291,8 @@ xfs_trans_read_buf(if (bp->b_error) { error = bp->b_error;xfs_buf_ioerror_alert (bp, __func__); +XFS_BUF_UNDONE (bp); +xfs_buf_stale (bp);xfs_buf_relse (bp);return error; }
Signature · 6 lines
1.7.9 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/3 xfs: kill XBF_DONTBLOCK
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Just about all callers of xfs_buf_read() and xfs_buf_get() use XBF_DONTBLOCK. This is used to make memory allocation use GFP_NOFS rather than GFP_KERNEL to avoid recursion through memory reclaim back into the filesystem.
All the blocking get calls in growfs occur inside a transaction, even though they are no part of the transaction, so all allocation will be GFP_NOFS due to the task flag PF_TRANS being set. The blocking read calls occur during log recovery, so they will probably be unaffected by converting to GFP_NOFS allocations.
Hence make XBF_DONTBLOCK behaviour always occur for buffers and kill the flag.
--- fs/xfs/xfs_attr.c | 3 +-- fs/xfs/xfs_buf.c | 18 +++++++----------- fs/xfs/xfs_buf.h | 2 -- fs/xfs/xfs_trans_buf.c | 25 ++++--------------------- fs/xfs/xfs_vnodeops.c | 4 ++-- 5 files changed, 14 insertions(+), 38 deletions(-)
fs/xfs/xfs_attr.c +1 -2
@@ -2114,8 +2114,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) dblkno =XFS_FSB_TO_DADDR (mp, map.br_startblock), blkcnt =XFS_FSB_TO_BB (mp, map.br_blockcount); - bp =xfs_buf_get (mp->m_ddev_targp, dblkno, blkcnt, -XBF_DONT_BLOCK ); + bp =xfs_buf_get (mp->m_ddev_targp, dblkno, blkcnt,0 );if (!bp)return ENOMEM ;
fs/xfs/xfs_buf.c +7 -11
@@ -56,11 +56,7 @@ static struct workqueue_struct *xfslogd_workqueue;#endif #define xb_to_gfp (flags) \ - ((((flags) & XBF_READ_AHEAD) ? __GFP_NORETRY : \ - ((flags) & XBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) - -#define xb_to_km (flags) \ - (((flags) & XBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) + ((((flags) & XBF_READ_AHEAD) ? __GFP_NORETRY : GFP_NOFS) | __GFP_NOWARN) static inline int
@@ -172,14 +168,14 @@ xfs_buf_alloc( {struct xfs_buf *bp; - bp =kmem_zone_zalloc (xfs_buf_zone,xb_to_km (flags)); + bp =kmem_zone_zalloc (xfs_buf_zone,KM_NOFS );if (unlikely (!bp))return NULL ;/* * We don't want certain flags to appear in b_flags. */ - flags &= ~(XBF_MAPPED |XBF_DONT_BLOCK |XBF_READ_AHEAD ); + flags &= ~(XBF_MAPPED |XBF_READ_AHEAD );atomic_set (&bp->b_hold,1 );atomic_set (&bp->b_lru_ref,1 );
@@ -233,7 +229,7 @@ _xfs_buf_get_pages( bp->b_pages = bp->b_page_array; }else { bp->b_pages =kmem_alloc (sizeof (struct page *) * - page_count,xb_to_km (flags)); + page_count,KM_NOFS );if (bp->b_pages ==NULL )return -ENOMEM ; }
@@ -310,7 +306,7 @@ xfs_buf_allocate_memory(*/ size =BBTOB (bp->b_length);if (size <PAGE_SIZE ) { - bp->b_addr =kmem_alloc (size,xb_to_km (flags)); + bp->b_addr =kmem_alloc (size,KM_NOFS );if (!bp->b_addr) {/* low memory - use alloc_page loop instead */ goto use_alloc_page;
@@ -653,7 +649,7 @@ xfs_buf_readahead(return ;xfs_buf_read (target, blkno, numblks, -XBF_TRYLOCK |XBF_ASYNC |XBF_READ_AHEAD |XBF_DONT_BLOCK ); +XBF_TRYLOCK |XBF_ASYNC |XBF_READ_AHEAD ); }/*
@@ -744,7 +740,7 @@ xfs_buf_associate_memory( bp->b_pages =NULL ; bp->b_addr = mem; - rval =_xfs_buf_get_pages (bp, page_count,XBF_DONT_BLOCK ); + rval =_xfs_buf_get_pages (bp, page_count,0 );if (rval)return rval;
fs/xfs/xfs_buf.h +0 -2
@@ -53,7 +53,6 @@ typedef enum {/* flags used only as arguments to access routines */ #define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ -#define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */ /* flags used only internally */ #define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
@@ -74,7 +73,6 @@ typedef unsigned int xfs_buf_flags_t; { XBF_FUA, "FUA" }, \ { XBF_FLUSH, "FLUSH" }, \ { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\ - { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ { _XBF_PAGES, "PAGES" }, \ { _XBF_KMEM, "KMEM" }, \ { _XBF_DELWRI_Q, "DELWRI_Q" }
fs/xfs/xfs_trans_buf.c +4 -21
@@ -148,8 +148,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,* Default to a normal get_buf() call if the tp is NULL. */ if (tp ==NULL ) -return xfs_buf_get (target_dev, blkno, len, - flags |XBF_DONT_BLOCK ); +return xfs_buf_get (target_dev, blkno, len, flags);/* * If we find the buffer in the cache with this transaction
@@ -174,15 +173,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,return (bp); } -/* -* We always specify the XBF_DONT_BLOCK flag within a transaction -* so that get_buf does not try to push out a delayed write buffer -* which might cause another transaction to take place (if the -* buffer was delayed alloc). Such recursive transactions can -* easily deadlock with our current transaction as well as cause -* us to run out of stack space. -*/ - bp =xfs_buf_get (target_dev, blkno, len, flags |XBF_DONT_BLOCK ); + bp =xfs_buf_get (target_dev, blkno, len, flags);if (bp ==NULL ) {return NULL ; }
@@ -283,7 +274,7 @@ xfs_trans_read_buf(* Default to a normal get_buf() call if the tp is NULL. */ if (tp ==NULL ) { - bp =xfs_buf_read (target, blkno, len, flags |XBF_DONT_BLOCK ); + bp =xfs_buf_read (target, blkno, len, flags);if (!bp)return (flags &XBF_TRYLOCK ) ?EAGAIN :XFS_ERROR (ENOMEM );
@@ -367,15 +358,7 @@ xfs_trans_read_buf(return 0 ; } -/* -* We always specify the XBF_DONT_BLOCK flag within a transaction -* so that get_buf does not try to push out a delayed write buffer -* which might cause another transaction to take place (if the -* buffer was delayed alloc). Such recursive transactions can -* easily deadlock with our current transaction as well as cause -* us to run out of stack space. -*/ - bp =xfs_buf_read (target, blkno, len, flags |XBF_DONT_BLOCK ); + bp =xfs_buf_read (target, blkno, len, flags);if (bp ==NULL ) { *bpp =NULL ; return (flags & XBF_TRYLOCK) ?
fs/xfs/xfs_vnodeops.c +2 -2
@@ -82,7 +82,7 @@ xfs_readlink_bmap( byte_cnt =XFS_FSB_TO_B (mp, mval[n].br_blockcount); bp =xfs_buf_read (mp->m_ddev_targp, d,BTOBB (byte_cnt), -XBF_MAPPED |XBF_DONT_BLOCK ); +XBF_MAPPED );if (!bp)return XFS_ERROR (ENOMEM ); error = bp->b_error;
@@ -1966,7 +1966,7 @@ xfs_zero_remaining_bytes( bp =xfs_buf_get_uncached (XFS_IS_REALTIME_INODE (ip) ? mp->m_rtdev_targp : mp->m_ddev_targp, -BTOBB (mp->m_sb.sb_blocksize),XBF_DONT_BLOCK ); +BTOBB (mp->m_sb.sb_blocksize),0 );if (!bp)return XFS_ERROR (ENOMEM );
Signature · 6 lines
1.7.9 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/3 xfs: kill XBF_LOCK
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Buffers are always returned locked from the lookup routines. Hence we don't need to tell the lookup routines to return locked buffers, on to try and lock them. Remove XBF_LOCK from all the callers and from internal buffer cache usage.
--- fs/xfs/xfs_attr.c | 5 ++--- fs/xfs/xfs_attr_leaf.c | 2 +- fs/xfs/xfs_buf.c | 20 +++++--------------- fs/xfs/xfs_buf.h | 4 +--- fs/xfs/xfs_fsops.c | 13 +++++-------- fs/xfs/xfs_ialloc.c | 3 +-- fs/xfs/xfs_inode.c | 16 +++++++--------- fs/xfs/xfs_log_recover.c | 7 +++---- fs/xfs/xfs_rw.c | 2 +- fs/xfs/xfs_trans_buf.c | 4 ++-- fs/xfs/xfs_vnodeops.c | 2 +- 11 files changed, 29 insertions(+), 49 deletions(-)
fs/xfs/xfs_attr.c +2 -3
@@ -1988,8 +1988,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args) dblkno =XFS_FSB_TO_DADDR (mp, map[i].br_startblock); blkcnt =XFS_FSB_TO_BB (mp, map[i].br_blockcount); error =xfs_read_buf (mp, mp->m_ddev_targp, dblkno, - blkcnt,XBF_LOCK |XBF_DONT_BLOCK , - &bp); + blkcnt,XBF_DONT_BLOCK , &bp);if (error)return (error);
@@ -2116,7 +2115,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) blkcnt =XFS_FSB_TO_BB (mp, map.br_blockcount); bp =xfs_buf_get (mp->m_ddev_targp, dblkno, blkcnt, -XBF_LOCK |XBF_DONT_BLOCK ); +XBF_DONT_BLOCK );if (!bp)return ENOMEM ;
fs/xfs/xfs_attr_leaf.c +1 -1
@@ -2983,7 +2983,7 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, map.br_blockcount); bp =xfs_trans_get_buf (*trans, dp->i_mount->m_ddev_targp, - dblkno, dblkcnt,XBF_LOCK ); + dblkno, dblkcnt,0 );if (!bp)return ENOMEM ;xfs_trans_binval (*trans, bp);
fs/xfs/xfs_buf.c +5 -15
@@ -179,7 +179,7 @@ xfs_buf_alloc(/* * We don't want certain flags to appear in b_flags. */ - flags &= ~(XBF_LOCK |XBF_MAPPED |XBF_DONT_BLOCK |XBF_READ_AHEAD ); + flags &= ~(XBF_MAPPED |XBF_DONT_BLOCK |XBF_READ_AHEAD );atomic_set (&bp->b_hold,1 );atomic_set (&bp->b_lru_ref,1 );
@@ -578,19 +578,14 @@ found:if (unlikely (error)) {xfs_warn (target->bt_mount,"%s: failed to map pages\n" , __func__); - goto no_buffer; +xfs_buf_relse (bp); +return NULL ; } }XFS_STATS_INC (xb_get);trace_xfs_buf_get (bp, flags, _RET_IP_);return bp; - -no_buffer: -if (flags & (XBF_LOCK |XBF_TRYLOCK )) -xfs_buf_unlock (bp); -xfs_buf_rele (bp); -return NULL ; }STATIC int
@@ -633,7 +628,8 @@ xfs_buf_read(* Read ahead call which is already satisfied, * drop the buffer */ - goto no_buffer; +xfs_buf_relse (bp); +return NULL ; }else {/* We do not want read in the flags */ bp->b_flags &= ~XBF_READ ;
@@ -641,12 +637,6 @@ xfs_buf_read( }return bp; - - no_buffer: -if (flags & (XBF_LOCK |XBF_TRYLOCK )) -xfs_buf_unlock (bp); -xfs_buf_rele (bp); -return NULL ; }/*
fs/xfs/xfs_buf.h +1 -3
@@ -52,7 +52,6 @@ typedef enum {#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */ /* flags used only as arguments to access routines */ -#define XBF_LOCK (1 << 15)/* lock requested */ #define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ #define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */
@@ -74,8 +73,7 @@ typedef unsigned int xfs_buf_flags_t; { XBF_SYNCIO, "SYNCIO" }, \ { XBF_FUA, "FUA" }, \ { XBF_FLUSH, "FLUSH" }, \ - { XBF_LOCK, "LOCK" }, /* should never be set */\ - { XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\ + { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\ { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ { _XBF_PAGES, "PAGES" }, \ { _XBF_KMEM, "KMEM" }, \
fs/xfs/xfs_fsops.c +5 -8
@@ -193,7 +193,7 @@ xfs_growfs_data_private(*/ bp =xfs_buf_get (mp->m_ddev_targp,XFS_AG_DADDR (mp, agno,XFS_AGF_DADDR (mp)), -XFS_FSS_TO_BB (mp,1 ),XBF_LOCK |XBF_MAPPED ); +XFS_FSS_TO_BB (mp,1 ),XBF_MAPPED );if (!bp) { error =ENOMEM ; goto error0;
@@ -230,7 +230,7 @@ xfs_growfs_data_private(*/ bp =xfs_buf_get (mp->m_ddev_targp,XFS_AG_DADDR (mp, agno,XFS_AGI_DADDR (mp)), -XFS_FSS_TO_BB (mp,1 ),XBF_LOCK |XBF_MAPPED ); +XFS_FSS_TO_BB (mp,1 ),XBF_MAPPED );if (!bp) { error =ENOMEM ; goto error0;
@@ -259,8 +259,7 @@ xfs_growfs_data_private(*/ bp =xfs_buf_get (mp->m_ddev_targp,XFS_AGB_TO_DADDR (mp, agno,XFS_BNO_BLOCK (mp)), -BTOBB (mp->m_sb.sb_blocksize), -XBF_LOCK |XBF_MAPPED ); +BTOBB (mp->m_sb.sb_blocksize),XBF_MAPPED );if (!bp) { error =ENOMEM ; goto error0;
@@ -286,8 +285,7 @@ xfs_growfs_data_private(*/ bp =xfs_buf_get (mp->m_ddev_targp,XFS_AGB_TO_DADDR (mp, agno,XFS_CNT_BLOCK (mp)), -BTOBB (mp->m_sb.sb_blocksize), -XBF_LOCK |XBF_MAPPED ); +BTOBB (mp->m_sb.sb_blocksize),XBF_MAPPED );if (!bp) { error =ENOMEM ; goto error0;
@@ -314,8 +312,7 @@ xfs_growfs_data_private(*/ bp =xfs_buf_get (mp->m_ddev_targp,XFS_AGB_TO_DADDR (mp, agno,XFS_IBT_BLOCK (mp)), -BTOBB (mp->m_sb.sb_blocksize), -XBF_LOCK |XBF_MAPPED ); +BTOBB (mp->m_sb.sb_blocksize),XBF_MAPPED );if (!bp) { error =ENOMEM ; goto error0;
fs/xfs/xfs_ialloc.c +1 -2
@@ -200,8 +200,7 @@ xfs_ialloc_inode_init(*/ d =XFS_AGB_TO_DADDR (mp, agno, agbno + (j * blks_per_cluster)); fbuf =xfs_trans_get_buf (tp, mp->m_ddev_targp, d, - mp->m_bsize * blks_per_cluster, -XBF_LOCK ); + mp->m_bsize * blks_per_cluster,0 );if (!fbuf)return ENOMEM ;/*
fs/xfs/xfs_inode.c +7 -9
@@ -226,7 +226,7 @@ xfs_inotobp(if (error)return error; - error =xfs_imap_to_bp (mp, tp, &imap, &bp,XBF_LOCK , imap_flags); + error =xfs_imap_to_bp (mp, tp, &imap, &bp,0 , imap_flags);if (error)return error;
@@ -782,8 +782,7 @@ xfs_iread(/* * Get pointers to the on-disk inode and the buffer containing it. */ - error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &bp, -XBF_LOCK , iget_flags); + error =xfs_imap_to_bp (mp, tp, &ip->i_imap, &bp,0 , iget_flags);if (error)return error; dip = (xfs_dinode_t *)xfs_buf_offset (bp, ip->i_imap.im_boffset);
@@ -1342,7 +1341,7 @@ xfs_iunlink(* Here we put the head pointer into our next pointer, * and then we fall through to point the head at us. */ - error =xfs_itobp (mp, tp, ip, &dip, &ibp,XBF_LOCK ); + error =xfs_itobp (mp, tp, ip, &dip, &ibp,0 );if (error)return error;
@@ -1423,7 +1422,7 @@ xfs_iunlink_remove(* of dealing with the buffer when there is no need to * change it. */ - error =xfs_itobp (mp, tp, ip, &dip, &ibp,XBF_LOCK ); + error =xfs_itobp (mp, tp, ip, &dip, &ibp,0 );if (error) {xfs_warn (mp,"%s: xfs_itobp() returned error %d." , __func__, error);
@@ -1484,7 +1483,7 @@ xfs_iunlink_remove(* Now last_ibp points to the buffer previous to us on * the unlinked list. Pull us from the list. */ - error =xfs_itobp (mp, tp, ip, &dip, &ibp,XBF_LOCK ); + error =xfs_itobp (mp, tp, ip, &dip, &ibp,0 );if (error) {xfs_warn (mp,"%s: xfs_itobp(2) returned error %d." , __func__, error);
@@ -1566,8 +1565,7 @@ xfs_ifree_cluster(* to mark all the active inodes on the buffer stale. */ bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, blkno, - mp->m_bsize * blks_per_cluster, -XBF_LOCK ); + mp->m_bsize * blks_per_cluster,0 );if (!bp)return ENOMEM ;
@@ -1737,7 +1735,7 @@ xfs_ifree(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); - error =xfs_itobp (ip->i_mount, tp, ip, &dip, &ibp,XBF_LOCK ); + error =xfs_itobp (ip->i_mount, tp, ip, &dip, &ibp,0 );if (error)return error;
fs/xfs/xfs_log_recover.c +3 -4
@@ -2127,7 +2127,7 @@ xlog_recover_buffer_pass2(trace_xfs_log_recover_buf_recover (log, buf_f); - buf_flags =XBF_LOCK ; + buf_flags =0 ;if (!(buf_f->blf_flags &XFS_BLF_INODE_BUF )) buf_flags |=XBF_MAPPED ;
@@ -2225,8 +2225,7 @@ xlog_recover_inode_pass2( }trace_xfs_log_recover_inode_recover (log, in_f); - bp =xfs_buf_read (mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, -XBF_LOCK ); + bp =xfs_buf_read (mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,0 );if (!bp) { error =ENOMEM ; goto error;
@@ -3099,7 +3098,7 @@ xlog_recover_process_one_iunlink(/* * Get the on disk inode to find the next inode in the bucket. */ - error =xfs_itobp (mp,NULL , ip, &dip, &ibp,XBF_LOCK ); + error =xfs_itobp (mp,NULL , ip, &dip, &ibp,0 );if (error) goto fail_iput;
fs/xfs/xfs_rw.c +1 -1
@@ -114,7 +114,7 @@ xfs_read_buf(int error;if (!flags) - flags =XBF_LOCK |XBF_MAPPED ; + flags =XBF_MAPPED ; bp =xfs_buf_read (target, blkno, len, flags);if (!bp)
fs/xfs/xfs_trans_buf.c +2 -2
@@ -142,7 +142,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,xfs_buf_log_item_t *bip;if (flags ==0 ) - flags =XBF_LOCK |XBF_MAPPED ; + flags =XBF_MAPPED ;/* * Default to a normal get_buf() call if the tp is NULL.
@@ -275,7 +275,7 @@ xfs_trans_read_buf(int error;if (flags ==0 ) - flags =XBF_LOCK |XBF_MAPPED ; + flags =XBF_MAPPED ;/* * Default to a normal get_buf() call if the tp is NULL.
fs/xfs/xfs_vnodeops.c +1 -1
@@ -82,7 +82,7 @@ xfs_readlink_bmap( byte_cnt =XFS_FSB_TO_B (mp, mval[n].br_blockcount); bp =xfs_buf_read (mp->m_ddev_targp, d,BTOBB (byte_cnt), -XBF_LOCK |XBF_MAPPED |XBF_DONT_BLOCK ); +XBF_MAPPED |XBF_DONT_BLOCK );if (!bp)return XFS_ERROR (ENOMEM ); error = bp->b_error;
Signature · 6 lines
1.7.9 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
Quoted 46 lines · Dave Chinner
From: Dave Chinner<[email protected]>
Buffers are always returned locked from the lookup routines. Hence we don't need to tell the lookup routines to return locked buffers, on to try and lock them. Remove
XBF_LOCKfrom all the callers and from internal buffer cache usage.Signed-off-by Dave Chinner<[email protected]>--- fs/xfs/xfs_attr.c | 5 ++--- fs/xfs/xfs_attr_leaf.c | 2 +- fs/xfs/xfs_buf.c | 20 +++++--------------- fs/xfs/xfs_buf.h | 4 +--- fs/xfs/xfs_fsops.c | 13 +++++-------- fs/xfs/xfs_ialloc.c | 3 +-- fs/xfs/xfs_inode.c | 16 +++++++--------- fs/xfs/xfs_log_recover.c | 7 +++---- fs/xfs/xfs_rw.c | 2 +- fs/xfs/xfs_trans_buf.c | 4 ++-- fs/xfs/xfs_vnodeops.c | 2 +- 11 files changed, 29 insertions(+), 49 deletions(-)fs/xfs/xfs_buf.c +3
-2@@ -179,7 +179,7 @@ xfs_buf_alloc(/* * We don't want certain flags to appear in b_flags. */ - flags&= ~(XBF_LOCK |XBF_MAPPED |XBF_DONT_BLOCK |XBF_READ_AHEAD ); + flags&= ~(XBF_MAPPED |XBF_DONT_BLOCK |XBF_READ_AHEAD );atomic_set (&bp->b_hold,1 );atomic_set (&bp->b_lru_ref,1 );@@ -578,19 +578,14 @@ found:if (unlikely (error)) {xfs_warn (target->bt_mount,"%s: failed to map pages\n" , __func__); - goto no_buffer; +xfs_buf_relse (bp); +return NULL ; } }
fs/xfs/xfs_buf.c found: · line 589
Quoted 10 lines
fs/xfs/xfs_buf.c +0
-6XFS_STATS_INC (xb_get);trace_xfs_buf_get (bp, flags, _RET_IP_);return bp; - -no_buffer: -if (flags& (XBF_LOCK |XBF_TRYLOCK )) -xfs_buf_unlock (bp); -xfs_buf_rele (bp); -return NULL ; }
Do you have a new copy of the "xfs: fix buffer lookup race on allocation failure" patch. It would go about here in the sources.
The reason I ask, the sources that I have for xfs_buf_get() seems to still have a "goto no_buffer" for the failed xfs_buf_allocate_memory() call and this patch removes that call. I did not find anything in the 8 buf clean-up series that would alter this area.
Thank-you,
--Mark Tinguely <[email protected]>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
Quoted 7 lines · Mark Tinguely
Quoted 6 lines · Dave Chinner
From: Dave Chinner<[email protected]>
Buffers are always returned locked from the lookup routines. Hence we don't need to tell the lookup routines to return locked buffers, on to try and lock them. Remove
XBF_LOCKfrom all the callers and from internal buffer cache usage.
.....
Quoted 11 lines
fs/xfs/xfs_buf.c found: · line 589
Quoted 6 lines
fs/xfs/xfs_buf.c +0
-5-no_buffer: -if (flags& (XBF_LOCK |XBF_TRYLOCK )) -xfs_buf_unlock (bp); -xfs_buf_rele (bp); -return NULL ; }Do you have a new copy of the "xfs: fix buffer lookup race on allocation failure" patch. It would go about here in the sources.
Quoted 5 lines
The reason I ask, the sources that I have for
xfs_buf_get()seems to still have a "gotono_buffer" for the failedxfs_buf_allocate_memory()call and this patch removes that call. I did not find anything in the 8 buf clean-up series that would alter this area.
I'm sure I posted it previously. Let me update all the reviewed-by tags and I'll resend the entire series....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
In reply to Dave ChinnerLooks good, although it will have context clashes with my imap changes.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/3] xfs: kill xfs_read_buf()
In reply to Dave ChinnerLooks good in general, but I'd be tempted to say the semantics changes to xfs_trans_read_buf should be a separate patch from killing xfs_read_buf.
Either way:
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 3/3] xfs: kill XBF_DONTBLOCK
In reply to Dave ChinnerLooks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
In reply to Dave ChinnerQuoted 8 lines · Dave Chinner
Quoted 5 lines
The reason I ask, the sources that I have for
xfs_buf_get()seems to still have a "gotono_buffer" for the failedxfs_buf_allocate_memory()call and this patch removes that call. I did not find anything in the 8 buf clean-up series that would alter this area.I'm sure I posted it previously. Let me update all the reviewed-by tags and I'll resend the entire series....
I think Mark meant the patch to fix the error handling for failed allocation, which needs to be redone to only insert the buffer into the rbtree once it's fully set up.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Dave Chinner
These 3 patches sit on top of my recent series titled:
[PATCH 0/8] xfs: clean up unit usage in
xfs_bufV2These patches remove bits of the API that are effectively the default behaviour used by everything or are redundant. This just makes API usage simpler and gives it a smaller footprint to modify in future.
If you touch these interfaces any chance you could kill the impliciy XBF_MAPPED thing we do in various places? Probably best by reversing it and only pass in an XBF_UNMAPPED for the inode buffers as that's the only place where we want them.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Quoted 6 lines · Dave Chinner
Quoted 5 lines
The reason I ask, the sources that I have for
xfs_buf_get()seems to still have a "gotono_buffer" for the failedxfs_buf_allocate_memory()call and this patch removes that call. I did not find anything in the 8 buf clean-up series that would alter this area.
Quoted 6 lines
Quoted 2 lines
I'm sure I posted it previously. Let me update all the reviewed-by tags and I'll resend the entire series....
I think Mark meant the patch to fix the error handling for failed allocation, which needs to be redone to only insert the buffer into the rbtree once it's fully set up.
Right. What I meant was that I need to resend the entire 12-13 buffer cache patches I have in my queue right now so that they should all apply easily...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
Quoted 3 lines · Dave Chinner
Right. What I meant was that I need to resend the entire 12-13 buffer cache patches I have in my queue right now so that they should all apply easily...
Can you make sure the allocation fix is first in the series? That's material for 3.4-rc and stable backports.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Dave Chinner
Right. What I meant was that I need to resend the entire 12-13 buffer cache patches I have in my queue right now so that they should all apply easily...
Can you make sure the allocation fix is first in the series? That's material for 3.4-rc and stable backports.
It is ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfs: kill XBF_LOCK
In reply to Christoph HellwigQuoted 10 lines · Christoph Hellwig
Quoted 8 lines · Dave Chinner
Quoted 5 lines
The reason I ask, the sources that I have for
xfs_buf_get()seems to still have a "gotono_buffer" for the failedxfs_buf_allocate_memory()call and this patch removes that call. I did not find anything in the 8 buf clean-up series that would alter this area.I'm sure I posted it previously. Let me update all the reviewed-by tags and I'll resend the entire series....
Quoted 8 lines
I think Mark meant the patch to fix the error handling for failed allocation, which needs to be redone to only insert the buffer into the rbtree once it's fully set up.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
That is correct.
The series in general looked good to me.
--Mark Tinguely.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Dave Chinner
These 3 patches sit on top of my recent series titled:
[PATCH 0/8] xfs: clean up unit usage in
xfs_bufV2These patches remove bits of the API that are effectively the default behaviour used by everything or are redundant. This just makes API usage simpler and gives it a smaller footprint to modify in future.
Quoted 4 lines
If you touch these interfaces any chance you could kill the impliciy
XBF_MAPPEDthing we do in various places? Probably best by reversing it and only pass in anXBF_UNMAPPEDfor the inode buffers as that's the only place where we want them.
Sounds like a good idea. I'll write a patch to do this....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs