xfs: compound buffers for directory blocks
PATCH 1/12 xfs: remove remaining scraps of struct xfs_iomap
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- fs/xfs/xfs_vnode.h | 1 - fs/xfs/xfs_vnodeops.h | 3 --- 2 files changed, 0 insertions(+), 4 deletions(-)
fs/xfs/xfs_vnode.h +0 -1
@@ -22,7 +22,6 @@struct file ;struct xfs_inode ; -struct xfs_iomap ;struct attrlist_cursor_kern ;/*
fs/xfs/xfs_vnodeops.h +0 -3
@@ -10,7 +10,6 @@ struct kiocb;struct pipe_inode_info ;struct uio ;struct xfs_inode ; -struct xfs_iomap ;int xfs_setattr_nonsize (struct xfs_inode *ip,struct iattr *vap,int flags);
@@ -49,8 +48,6 @@ int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name,int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name,int flags);int xfs_attr_list (struct xfs_inode *dp,char *buffer,int bufsize,int flags,struct attrlist_cursor_kern *cursor); -int xfs_bmap (struct xfs_inode *ip,xfs_off_t offset,ssize_t count, -int flags,struct xfs_iomap *iomapp,int *niomaps);void xfs_tosspages (struct xfs_inode *inode,xfs_off_t first,xfs_off_t last,int fiopt); int xfs_flushinval_pages(struct xfs_inode *ip, xfs_off_t first,
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/12 xfs: clean up buffer get/read call API
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The xfs_buf_get/read API is not consistent in the units it uses, and does not use appropriate or consistent units/types for the variables.
Convert the API to use disk addresses and block counts for all buffer get and read calls. Use consistent naming for all the functions and their declarations, and convert the internal functions to use disk addresses and block counts to avoid need to convert them from one type to another and back again.
Fix all the callers to use disk addresses and block counts. In many cases, this removes an additional conversion from the function call as the callers already have a block count.
--- fs/xfs/xfs_buf.c | 81 +++++++++++++++++++++++---------------------- fs/xfs/xfs_buf.h | 38 ++++++++++++---------- fs/xfs/xfs_fsops.c | 4 +- fs/xfs/xfs_log.c | 6 ++-- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_mount.c | 12 +++--- fs/xfs/xfs_rtalloc.c | 8 ++-- fs/xfs/xfs_vnodeops.c | 2 +- 8 files changed, 79 insertions(+), 74 deletions(-)
fs/xfs/xfs_buf.c +41 -40
@@ -166,8 +166,8 @@ xfs_buf_stale(struct xfs_buf *xfs_buf_alloc (struct xfs_buftarg *target, -xfs_off_t range_base, -size_t range_length, +xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags) {struct xfs_buf *bp;
@@ -191,14 +191,16 @@ xfs_buf_alloc(sema_init (&bp->b_sema,0 );/* held, no waiters */ XB_SET_OWNER (bp); bp->b_target = target; - bp->b_file_offset = range_base; + bp->b_file_offset = blkno <<BBSHIFT ;/* * Set buffer_length and count_desired to the same value initially. * I/O routines should use count_desired, which will be the same in * most cases but may be reset (e.g. XFS recovery). */ - bp->b_buffer_length = bp->b_count_desired = range_length; + bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; bp->b_flags = flags; + +/* XXX: we have the block number. Why don't we just set it here? */ bp->b_bn =XFS_BUF_DADDR_NULL ;atomic_set (&bp->b_pin_count,0 );init_waitqueue_head (&bp->b_waiters);
@@ -422,29 +424,29 @@ _xfs_buf_map_pages(*/ xfs_buf_t *_xfs_buf_find ( -xfs_buftarg_t *btp,/* block device target */ -xfs_off_t ioff,/* starting offset of range */ -size_t isize,/* length of range */ +xfs_buftarg_t *btp, +xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags,xfs_buf_t *new_bp) { -xfs_off_t range_base; -size_t range_length; +xfs_off_t offset; +size_t numbytes;struct xfs_perag *pag;struct rb_node **rbp;struct rb_node *parent;xfs_buf_t *bp; - range_base = (ioff <<BBSHIFT ); - range_length = (isize <<BBSHIFT ); + offset = blkno <<BBSHIFT ; + numbytes = numblks <<BBSHIFT ;/* Check for IOs smaller than the sector size / not sector aligned */ -ASSERT (!(range_length < (1 << btp->bt_sshift))); -ASSERT (!(range_base & (xfs_off_t )btp->bt_smask)); +ASSERT (!(numbytes < (1 << btp->bt_sshift))); +ASSERT (!(offset & (xfs_off_t )btp->bt_smask));/* get tree root */ pag =xfs_perag_get (btp->bt_mount, -xfs_daddr_to_agno (btp->bt_mount, ioff)); +xfs_daddr_to_agno (btp->bt_mount, blkno));/* walk tree */ spin_lock (&pag->pag_buf_lock);
@@ -455,9 +457,9 @@ _xfs_buf_find( parent = *rbp; bp = rb_entry(parent, struct xfs_buf, b_rbnode); -if (range_base < bp->b_file_offset) +if (offset < bp->b_file_offset) rbp = &(*rbp)->rb_left; -else if (range_base > bp->b_file_offset) +else if (offset > bp->b_file_offset) rbp = &(*rbp)->rb_right;else {/*
@@ -468,7 +470,7 @@ _xfs_buf_find(* reallocating a busy extent. Skip this buffer and * continue searching to the right for an exact match. */ -if (bp->b_buffer_length != range_length) { +if (bp->b_buffer_length != numbytes) {ASSERT (bp->b_flags &XBF_STALE ); rbp = &(*rbp)->rb_right;continue ;
@@ -528,25 +530,24 @@ found:*/ struct xfs_buf *xfs_buf_get ( -xfs_buftarg_t *target,/* target for buffer */ -xfs_off_t ioff,/* starting offset of range */ -size_t isize,/* length of range */ +xfs_buftarg_t *target, +xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags) {struct xfs_buf *bp;struct xfs_buf *new_bp;int error =0 ; - bp =_xfs_buf_find (target, ioff, isize, flags,NULL ); + bp =_xfs_buf_find (target, blkno, numblks, flags,NULL );if (likely (bp)) goto found; - new_bp =xfs_buf_alloc (target, ioff <<BBSHIFT , isize <<BBSHIFT , - flags); + new_bp =xfs_buf_alloc (target, blkno, numblks, flags);if (unlikely (!new_bp))return NULL ; - bp =_xfs_buf_find (target, ioff, isize, flags, new_bp); + bp =_xfs_buf_find (target, blkno, numblks, flags, new_bp);if (!bp) {kmem_zone_free (xfs_buf_zone, new_bp);return NULL ;
@@ -563,7 +564,7 @@ xfs_buf_get(* Now we have a workable buffer, fill in the block number so * that we can do IO on it. */ - bp->b_bn = ioff; + bp->b_bn = blkno; bp->b_count_desired = bp->b_buffer_length; found:
@@ -609,15 +610,15 @@ _xfs_buf_read(xfs_buf_t *xfs_buf_read (xfs_buftarg_t *target, -xfs_off_t ioff, -size_t isize, +xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags) {xfs_buf_t *bp; flags |=XBF_READ ; - bp =xfs_buf_get (target, ioff, isize, flags); + bp =xfs_buf_get (target, blkno, numblks, flags);if (bp) {trace_xfs_buf_read (bp, flags, _RET_IP_);
@@ -652,13 +653,13 @@ xfs_buf_read(void xfs_buf_readahead (xfs_buftarg_t *target, -xfs_off_t ioff, -size_t isize) +xfs_daddr_t blkno, +size_t numblks) {if (bdi_read_congested (target->bt_bdi))return ; -xfs_buf_read (target, ioff, isize, +xfs_buf_read (target, blkno, numblks,XBF_TRYLOCK |XBF_ASYNC |XBF_READ_AHEAD |XBF_DONT_BLOCK ); }
@@ -668,16 +669,15 @@ xfs_buf_readahead(*/ struct xfs_buf *xfs_buf_read_uncached ( -struct xfs_mount *mp,struct xfs_buftarg *target,xfs_daddr_t daddr, -size_t length, +size_t numblks,int flags) {xfs_buf_t *bp;int error; - bp =xfs_buf_get_uncached (target, length, flags); + bp =xfs_buf_get_uncached (target, numblks, flags);if (!bp)return NULL ;
@@ -685,7 +685,7 @@ xfs_buf_read_uncached(XFS_BUF_SET_ADDR (bp, daddr);XFS_BUF_READ (bp); -xfsbdstrat (mp, bp); +xfsbdstrat (target->bt_mount, bp); error =xfs_buf_iowait (bp);if (error || bp->b_error) {xfs_buf_relse (bp);
@@ -701,7 +701,7 @@ xfs_buf_read_uncached(void xfs_buf_set_empty (struct xfs_buf *bp, -size_t len) +size_t numblks) {if (bp->b_pages)_xfs_buf_free_pages (bp);
@@ -710,7 +710,7 @@ xfs_buf_set_empty( bp->b_page_count =0 ; bp->b_addr =NULL ; bp->b_file_offset =0 ; - bp->b_buffer_length = bp->b_count_desired = len; + bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; bp->b_bn =XFS_BUF_DADDR_NULL ; bp->b_flags &= ~XBF_MAPPED ; }
@@ -772,17 +772,18 @@ xfs_buf_associate_memory(xfs_buf_t *xfs_buf_get_uncached (struct xfs_buftarg *target, -size_t len, +size_t numblks,int flags) { -unsigned long page_count =PAGE_ALIGN (len) >>PAGE_SHIFT ; +unsigned long page_count;int error, i;xfs_buf_t *bp; - bp =xfs_buf_alloc (target,0 , len,0 ); + bp =xfs_buf_alloc (target,0 , numblks,0 );if (unlikely (bp ==NULL )) goto fail; + page_count =PAGE_ALIGN (numblks <<BBSHIFT ) >>PAGE_SHIFT ; error =_xfs_buf_get_pages (bp, page_count,0 );if (error) goto fail_free_buf;
fs/xfs/xfs_buf.h +21 -17
@@ -165,26 +165,30 @@ typedef struct xfs_buf {/* Finding and Reading Buffers */ -extern xfs_buf_t *_xfs_buf_find (xfs_buftarg_t *,xfs_off_t ,size_t , -xfs_buf_flags_t ,xfs_buf_t *); +struct xfs_buf *_xfs_buf_find (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags, +struct xfs_buf *new_bp);#define xfs_incore (buftarg,blkno,len,lockit) \ _xfs_buf_find(buftarg, blkno ,len, lockit, NULL) -extern xfs_buf_t *xfs_buf_get (xfs_buftarg_t *,xfs_off_t ,size_t , -xfs_buf_flags_t ); -extern xfs_buf_t *xfs_buf_read (xfs_buftarg_t *,xfs_off_t ,size_t , -xfs_buf_flags_t ); - -struct xfs_buf *xfs_buf_alloc (struct xfs_buftarg *,xfs_off_t ,size_t , -xfs_buf_flags_t ); -extern void xfs_buf_set_empty (struct xfs_buf *bp,size_t len); -extern xfs_buf_t *xfs_buf_get_uncached (struct xfs_buftarg *,size_t ,int ); -extern int xfs_buf_associate_memory (xfs_buf_t *,void *,size_t ); -extern void xfs_buf_hold (xfs_buf_t *); -extern void xfs_buf_readahead (xfs_buftarg_t *,xfs_off_t ,size_t ); -struct xfs_buf *xfs_buf_read_uncached (struct xfs_mount *mp, -struct xfs_buftarg *target, -xfs_daddr_t daddr,size_t length,int flags); +struct xfs_buf *xfs_buf_get (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags); +struct xfs_buf *xfs_buf_read (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags); +void xfs_buf_readahead (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks); + +struct xfs_buf *xfs_buf_get_empty (struct xfs_buftarg *target,size_t numblks); +struct xfs_buf *xfs_buf_alloc (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags); +void xfs_buf_set_empty (struct xfs_buf *bp,size_t numblks); +int xfs_buf_associate_memory (struct xfs_buf *bp,void *mem,size_t length); + +struct xfs_buf *xfs_buf_get_uncached (struct xfs_buftarg *target,size_t numblks, +int flags); +struct xfs_buf *xfs_buf_read_uncached (struct xfs_buftarg *target, +xfs_daddr_t daddr,size_t numblks,int flags); +void xfs_buf_hold (struct xfs_buf *bp);/* Releasing Buffers */ extern void xfs_buf_free (xfs_buf_t *);
fs/xfs/xfs_fsops.c +2 -2
@@ -147,9 +147,9 @@ xfs_growfs_data_private(if ((error =xfs_sb_validate_fsb_count (&mp->m_sb, nb)))return error; dpct = pct - mp->m_sb.sb_imax_pct; - bp =xfs_buf_read_uncached (mp, mp->m_ddev_targp, + bp =xfs_buf_read_uncached (mp->m_ddev_targp,XFS_FSB_TO_BB (mp, nb) -XFS_FSS_TO_BB (mp,1 ), -BBTOB (XFS_FSS_TO_BB (mp,1 )),0 ); +XFS_FSS_TO_BB (mp,1 ),0 );if (!bp)return EIO ;xfs_buf_relse (bp);
fs/xfs/xfs_log.c +3 -3
@@ -1047,7 +1047,7 @@ xlog_alloc_log(xfs_mount_t *mp,xlog_get_iclog_buffer_size (mp, log); error =ENOMEM ; - bp =xfs_buf_alloc (mp->m_logdev_targp,0 , log->l_iclog_size,0 ); + bp =xfs_buf_alloc (mp->m_logdev_targp,0 ,BTOBB (log->l_iclog_size),0 );if (!bp) goto out_free_log; bp->b_iodone = xlog_iodone;
@@ -1079,7 +1079,7 @@ xlog_alloc_log(xfs_mount_t *mp, prev_iclog = iclog; bp =xfs_buf_get_uncached (mp->m_logdev_targp, - log->l_iclog_size,0 ); +BTOBB (log->l_iclog_size),0 );if (!bp) goto out_free_iclog;
@@ -1448,7 +1448,7 @@ xlog_dealloc_log(xlog_t *log)* always need to ensure that the extra buffer does not point to memory * owned by another log buffer before we free it. */ -xfs_buf_set_empty (log->l_xbuf, log->l_iclog_size); +xfs_buf_set_empty (log->l_xbuf,BTOBB (log->l_iclog_size));xfs_buf_free (log->l_xbuf); iclog = log->l_iclog;
fs/xfs/xfs_log_recover.c +1 -1
@@ -120,7 +120,7 @@ xlog_get_bp( nbblks += log->l_sectBBsize; nbblks =round_up (nbblks, log->l_sectBBsize); - bp =xfs_buf_get_uncached (log->l_mp->m_logdev_targp,BBTOB (nbblks),0 ); + bp =xfs_buf_get_uncached (log->l_mp->m_logdev_targp, nbblks,0 );if (bp)xfs_buf_unlock (bp);return bp;
fs/xfs/xfs_mount.c +6 -6
@@ -681,8 +681,8 @@ xfs_readsb(xfs_mount_t *mp, int flags) sector_size =xfs_getsize_buftarg (mp->m_ddev_targp); reread: - bp =xfs_buf_read_uncached (mp, mp->m_ddev_targp, -XFS_SB_DADDR , sector_size,0 ); + bp =xfs_buf_read_uncached (mp->m_ddev_targp,XFS_SB_DADDR , +BTOBB (sector_size),0 );if (!bp) {if (loud)xfs_warn (mp,"SB buffer read failed" );
@@ -1030,9 +1030,9 @@ xfs_check_sizes(xfs_mount_t *mp)xfs_warn (mp,"filesystem size mismatch detected" );return XFS_ERROR (EFBIG ); } - bp =xfs_buf_read_uncached (mp, mp->m_ddev_targp, + bp =xfs_buf_read_uncached (mp->m_ddev_targp, d -XFS_FSS_TO_BB (mp,1 ), -BBTOB (XFS_FSS_TO_BB (mp,1 )),0 ); +XFS_FSS_TO_BB (mp,1 ),0 );if (!bp) {xfs_warn (mp,"last sector read failed" );return EIO ;
@@ -1045,9 +1045,9 @@ xfs_check_sizes(xfs_mount_t *mp)xfs_warn (mp,"log size mismatch detected" );return XFS_ERROR (EFBIG ); } - bp =xfs_buf_read_uncached (mp, mp->m_logdev_targp, + bp =xfs_buf_read_uncached (mp->m_logdev_targp, d -XFS_FSB_TO_BB (mp,1 ), -XFS_FSB_TO_B (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 );if (!bp) {xfs_warn (mp,"log device read failed" );return EIO ;
fs/xfs/xfs_rtalloc.c +4 -4
@@ -1871,9 +1871,9 @@ xfs_growfs_rt(/* * Read in the last block of the device, make sure it exists. */ - bp =xfs_buf_read_uncached (mp, mp->m_rtdev_targp, + bp =xfs_buf_read_uncached (mp->m_rtdev_targp,XFS_FSB_TO_BB (mp, nrblocks -1 ), -XFS_FSB_TO_B (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 );if (!bp)return EIO ;xfs_buf_relse (bp);
@@ -2220,9 +2220,9 @@ xfs_rtmount_init( (unsigned long long) mp->m_sb.sb_rblocks);return XFS_ERROR (EFBIG ); } - bp =xfs_buf_read_uncached (mp, mp->m_rtdev_targp, + bp =xfs_buf_read_uncached (mp->m_rtdev_targp, d -XFS_FSB_TO_BB (mp,1 ), -XFS_FSB_TO_B (mp,1 ),0 ); +XFS_FSB_TO_BB (mp,1 ),0 );if (!bp) {xfs_warn (mp,"realtime device size check failed" );return EIO ;
fs/xfs/xfs_vnodeops.c +1 -1
@@ -1969,7 +1969,7 @@ xfs_zero_remaining_bytes( bp =xfs_buf_get_uncached (XFS_IS_REALTIME_INODE (ip) ? mp->m_rtdev_targp : mp->m_ddev_targp, - mp->m_sb.sb_blocksize,XBF_DONT_BLOCK ); +BTOBB (mp->m_sb.sb_blocksize),XBF_DONT_BLOCK );if (!bp)return XFS_ERROR (ENOMEM );
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
cover xfs: compound buffers for directory blocks
This series is an infrastructure change needed to allow CRCs to be easily implemented on directory blocks. Directory blocks can be larger than filesytem blocks and are mapped like data in a file via the inode block map btree. Hence a given directory block can be made up of discontiguous filesystem blocks.
The current way of handling this is via the struct xfs_dabuf - a separate structure that tracks individual struct xfs_bufs for each discontiguous region of a directory block. This abstracts the discontiguity away from all the directory code by hiding it behind linear memory buffer and memcpy()ing to and from the underlying xfs_bufs as the dabuf is created and destroyed for each directory operation that operates in a given directory block. the struct xfs-bufs are cached, but the dabuf is not, leading to significant overhead in constructing, destroying and modifying large directory buffers.
Further, because CRCs requires a single CRC for each directory block, we need to keep the buffer in an aggregated state until we do IO on it and can run a CRC calculation callback. With the xfs_dabuf destroyed long before write IO occurs, there is no way to calculate the CRC sanely.
To solve this problem we effectively need the functionality of a xfs_dabuf in a struct xfs_buf. That is, an xfs-buf needs to be able to map a discontiguous block range and aggregate all the IO needed to read and write such a discontiguous buffer. Further, the buffer logging need to support discontiguous ranges as well, and translate the in-memory new construct into the existing individual discontigous buffer log format.
To do this, the xfs_buf has a block vector array added to it, similar in concept to the page array. When IO is issued, it issues separate Io for each vector in the block array, building the IO appropriately from the page array. In this way, we avoid the need for a separate memory buffer for the directory code to work on - it can work directly on the vmapped buffer address. hence we remove two memcpy()s from each large directory block modification. Adding a io count for each vector means that the current method of dispatching, completing and waiting for IO is unchanged.
Further, by modifying the buffer item formatting to deal with discontiguous buffers, we remove the need for the xfs_dabuf to interpose to select the correct xfs_buf to record the changes to. This means that compound buffers can be used completely transparently throughout the existing XFS codebase (not just the directory code) without any modification.
To build compound buffers, we need some method of specifying the block map. We already have a structure for this - the struct xfs_bmbt_irec, which is what xfs_bmapi_*() uses and is the native format for maps in the directory code. hence it makes sense to pass these into the buffer cache as a method of specifying discontiguous block ranges.
It makes further sense to use struct xfs_bmbt_irec as the internal representation of block ranges for all the buffer interfaces, but this requires one extension. That is, the bmbt format currently only supports filesystem block sized units (FSB) and metadata requires sector (disk) addressing (DADDR) units. This is easily handled by adding a new state value that is held in the xfs_bmbt_irec.br_state field to indicate what unit the xfs_bmbt_irec map is encoded in. With this, the irec format can be used throughout the buffer interfaces to support discontiguous buffers everywhere.
Finally, with al these changes, the struct xfs_dabuf is not necessary anymore, so can be removed.
The series passes xfstests on 4k/4k, 4k/512b, 64k/4k and 64k/512b (dirblksz/fsblksz) configurations without any new regressions, and survives 100 million inode fs_mark benchmarks on a 17TB filesystem using 4k/4k, 64k/512b and 64k/512b configurations.
Some of the series is a bit verbose - code is rearranged a couple of times to suite testing step by step (e.g. duplicate code in the patch that introduces a new interface, factor the duplication back out in a later patch), so could probably be done neater. However, I'd prefer not to have to redo the entire series to avoid this if the end result is substantially identical code - it's time consuming to make sure each patch doesn't break stuff and I'd like to try to get this into 3.3 so I can focus on the real goal (CRC support) ASAP.
Comments, flames and ridicule all welcome. :)
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/12 xfs: add compound buffer get and read interfaces
From: Dave Chinner <[email protected]>
For a compound buffer, we need to have some way of specifying all the extents that need to be part of the buffer in one structure. The dabuf code gets this directly from xfs_bmapi() in the form of an xfs_bmbt_irec array. It makes sense to simply use this as the method of transferring the information to the compound buffer get and read functions that are responsible for building such buffers.
Implement the get and read compound buffer functions using this interface. Initially only support a single irec map to simplify the initial implementation. Support for multiple records will be added in future commits.
--- fs/xfs/xfs_buf.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_buf.h | 10 +++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
fs/xfs/xfs_buf.c +78 -0
@@ -40,6 +40,8 @@#include "xfs_ag.h" #include "xfs_mount.h" #include "xfs_trace.h" +#include "xfs_bit.h" +#include "xfs_bmap_btree.h" static kmem_zone_t *xfs_buf_zone; STATIC int xfsbufd(void *);
@@ -670,6 +672,82 @@ xfs_buf_readahead( }/* +* XXX: only supports a single map for now +*/ +struct xfs_buf * +xfs_buf_get_irec ( +struct xfs_buftarg *target, +struct xfs_bmbt_irec *map, +int nmaps, +xfs_buf_flags_t flags) +{ +xfs_daddr_t blkno; +size_t numblks; +struct xfs_buf *bp; + +ASSERT_ALWAYS (nmaps ==1 ); + + blkno =XFS_FSB_TO_DADDR (target->bt_mount, map->br_startblock); + numblks =XFS_FSB_TO_BB (target->bt_mount, map->br_blockcount); + + bp =xfs_buf_get (target, blkno, numblks, flags); + +return bp; +} + +struct xfs_buf * +xfs_buf_read_irec ( +struct xfs_buftarg *target, +struct xfs_bmbt_irec *map, +int nmaps, +xfs_buf_flags_t flags) +{ +xfs_buf_t *bp; + + flags |=XBF_READ ; + + bp =xfs_buf_get_irec (target, map, nmaps, flags); +if (bp) { +trace_xfs_buf_read (bp, flags, _RET_IP_); + +if (!XFS_BUF_ISDONE (bp)) { +XFS_STATS_INC (xb_get_read); +_xfs_buf_read (bp, flags); + }else if (flags &XBF_ASYNC ) { +/* +* Read ahead call which is already satisfied, +* drop the buffer +*/ + goto no_buffer; + }else { +/* We do not want read in the flags */ + bp->b_flags &= ~XBF_READ ; + } + } + +return bp; + + no_buffer: +if (flags & (XBF_LOCK |XBF_TRYLOCK )) +xfs_buf_unlock (bp); +xfs_buf_rele (bp); +return NULL ; +} + +void +xfs_buf_readahead_irec ( +struct xfs_buftarg *target, +struct xfs_bmbt_irec *map, +int nmaps) +{ +if (bdi_read_congested (target->bt_bdi)) +return ; + +xfs_buf_read_irec (target, map, nmaps, +XBF_TRYLOCK |XBF_ASYNC |XBF_READ_AHEAD |XBF_DONT_BLOCK ); +} + +/* * Read an uncached buffer from disk. Allocates and returns a locked * buffer containing the disk contents or nothing. */
fs/xfs/xfs_buf.h +10 -0
@@ -122,6 +122,7 @@ typedef void (*xfs_buf_iodone_t)(struct xfs_buf *);#define XB_PAGES 2 +struct xfs_bmbt_irec ;struct xfs_buf_vec {xfs_daddr_t bv_bn;/* block number for I/O */ size_t bv_len;/* size of I/O */
@@ -189,6 +190,15 @@ struct xfs_buf *xfs_buf_read(struct xfs_buftarg *target, xfs_daddr_t blkno,void xfs_buf_readahead (struct xfs_buftarg *target,xfs_daddr_t blkno,size_t numblks); +struct xfs_buf *xfs_buf_get_irec (struct xfs_buftarg *target, +struct xfs_bmbt_irec *map,int nmaps, +xfs_buf_flags_t flags); +struct xfs_buf *xfs_buf_read_irec (struct xfs_buftarg *target, +struct xfs_bmbt_irec *map,int nmaps, +xfs_buf_flags_t flags); +void xfs_buf_readahead_irec (struct xfs_buftarg *target, +struct xfs_bmbt_irec *map,int nmaps); +struct xfs_buf *xfs_buf_get_empty (struct xfs_buftarg *target,size_t numblks);struct xfs_buf *xfs_buf_alloc (struct xfs_buftarg *target,xfs_daddr_t blkno,size_t numblks,xfs_buf_flags_t flags);
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 6/12 xfs: convert xfs_da_do_buf to use irec buffer interface
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Convert xfs_da_do_buf to use ithe new irec buffer interface. This is just a simple 1:1 conversion as the irec interface only support single maps at this point in time.
--- fs/xfs/xfs_da_btree.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
fs/xfs/xfs_da_btree.c +8 -6
@@ -2025,22 +2025,24 @@ xfs_da_do_buf( mappedbno =XFS_FSB_TO_DADDR (mp, mapp[i].br_startblock);if (i ==0 ) - *mappedbnop = mappedbno; + *mappedbnop =XFS_FSB_TO_DADDR (mp, + mapp[i].br_startblock); nmapped = (int )XFS_FSB_TO_BB (mp, mapp[i].br_blockcount);switch (caller) {case 0 : - bp =xfs_trans_get_buf (trans, mp->m_ddev_targp, - mappedbno, nmapped,0 ); + bp =xfs_trans_get_buf_irec (trans, mp->m_ddev_targp, + &mapp[i],1 ,0 ); error = bp ? bp->b_error :XFS_ERROR (EIO );break ;case 1 :case 2 : bp =NULL ; - error =xfs_trans_read_buf (mp, trans, mp->m_ddev_targp, - mappedbno, nmapped,0 , &bp); + error =xfs_trans_read_buf_irec (mp, trans, + mp->m_ddev_targp, &mapp[i],1 , +0 , &bp);break ;case 3 : -xfs_buf_readahead (mp->m_ddev_targp, mappedbno, nmapped); +xfs_buf_readahead_irec (mp->m_ddev_targp, &mapp[i],1 ); error =0 ; bp =NULL ;break ;
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/12 xfs: introduce a compound buffer construct
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The first step to replacing the dabuf infrastructure is to introduce a buffer construct that can support multiple block ranges in a single mapping.
Directory buffers back be made up of multiple extents, but are currently formed by creating individual buffers and them copying the data out of them into a dabuf structure. All dabuf operations then require walking all the underlying buffers to change the state of the underlying buffers, and once a dabuf is modified the contents need to be copied back to the underlying buffers before they are logged.
All of these operations can be done on a normal xfs_buf, but the normal xfs_buf does not support multiple disk block ranges or doing multiple disjoint I/Os to read or write a buffer. Supporting multiple disk block ranges is not difficult - we simply need to attach an iovec-like array to the buffer rather than just using a single block number and length.
Splitting the buffer up into multiple IOs for read and write is not difficult, either. We already track the number of IO remaining to complete an IO, so this can be used to wait for the multiple IO dispatched to complete (for both read and write).
The only interesting twist to this is logging the changes. We can treat the compound buffer as a single buffer for most purposes except for formatting the changes into the log. When formatting, we need to split the changes into a format item per underlying region so that recovery does not need to know about compound buffers and can recover each segment of a directory block indivdually as it does now. The fact that recovery will replay all or none of the transaction nesures this process is still atomic from a change recovery point of view.
This new sort of buffer will be known as a "compound buffer", and will be tagged with a flag to indicate it is such. Compound buffers will be indexed and cached by the block number of their initial segment and the length of the entire buffer.
Introduce the compound buffer flags and the block vector infrastructure needed to replace the existing block number indexing. Further patches will introduce the real compound buffer functionality.
--- fs/xfs/xfs_buf.c | 19 +++++++++++++------ fs/xfs/xfs_buf.h | 17 ++++++++++++++--- fs/xfs/xfs_trace.h | 8 ++++---- 3 files changed, 31 insertions(+), 13 deletions(-)
fs/xfs/xfs_buf.c +13 -6
@@ -201,7 +201,12 @@ xfs_buf_alloc( bp->b_flags = flags;/* XXX: we have the block number. Why don't we just set it here? */ - bp->b_bn =XFS_BUF_DADDR_NULL ; +/* initialise the buffer IO vector array appropriately */ + bp->b_vec_count =1 ; + bp->b_vec = &bp->b_vec_array[0 ]; + bp->b_vec[0 ].bv_bn =XFS_BUF_DADDR_NULL ; + bp->b_vec[0 ].bv_len = bp->b_buffer_length; +atomic_set (&bp->b_pin_count,0 );init_waitqueue_head (&bp->b_waiters);
@@ -564,7 +569,8 @@ xfs_buf_get(* Now we have a workable buffer, fill in the block number so * that we can do IO on it. */ - bp->b_bn = blkno; + bp->b_vec[0 ].bv_bn = blkno; + bp->b_vec[0 ].bv_len = bp->b_buffer_length; bp->b_count_desired = bp->b_buffer_length; found:
@@ -596,7 +602,7 @@ _xfs_buf_read(int status;ASSERT (!(flags & (XBF_DELWRI |XBF_WRITE ))); -ASSERT (bp->b_bn !=XFS_BUF_DADDR_NULL ); +ASSERT (bp->b_vec[0 ].bv_bn !=XFS_BUF_DADDR_NULL ); bp->b_flags &= ~(XBF_WRITE |XBF_ASYNC |XBF_DELWRI |XBF_READ_AHEAD ); bp->b_flags |= flags & (XBF_READ |XBF_ASYNC |XBF_READ_AHEAD );
@@ -711,7 +717,8 @@ xfs_buf_set_empty( bp->b_addr =NULL ; bp->b_file_offset =0 ; bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; - bp->b_bn =XFS_BUF_DADDR_NULL ; + bp->b_vec[0 ].bv_bn =XFS_BUF_DADDR_NULL ; + bp->b_vec[0 ].bv_len = bp->b_buffer_length; bp->b_flags &= ~XBF_MAPPED ; }
@@ -1185,7 +1192,7 @@ _xfs_buf_ioapply(struct bio *bio;int offset = bp->b_offset;int size = bp->b_count_desired; -sector_t sector = bp->b_bn; +sector_t sector = bp->b_vec[0 ].bv_bn; total_nr_pages = bp->b_page_count; map_i =0 ;
@@ -1678,7 +1685,7 @@ xfs_buf_cmp( struct xfs_buf *bp = container_of(b, struct xfs_buf, b_list);xfs_daddr_t diff; - diff = ap->b_bn - bp->b_bn; + diff = ap->b_vec[0 ].bv_bn - bp->b_vec[0 ].bv_bn;if (diff <0 )return -1 ;if (diff >0 )
fs/xfs/xfs_buf.h +14 -3
@@ -67,6 +67,7 @@ typedef enum {#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */ #define _XBF_KMEM (1 << 21)/* backed by heap memory */ #define _XBF_DELWRI_Q (1 << 22)/* buffer on delwri queue */ +#define _XBF_COMPOUND (1 << 23)/* compound buffer */ typedef unsigned int xfs_buf_flags_t ;
@@ -121,6 +122,12 @@ typedef void (*xfs_buf_iodone_t)(struct xfs_buf *);#define XB_PAGES 2 +struct xfs_buf_vec { +xfs_daddr_t bv_bn;/* block number for I/O */ +size_t bv_len;/* size of I/O */ +}; +#define XB_VECS 2 + typedef struct xfs_buf { /* * first cacheline holds all the fields needed for an uncontended cache
@@ -142,7 +149,6 @@ typedef struct xfs_buf {struct list_head b_list;struct xfs_perag *b_pag;/* contains rbtree root */ xfs_buftarg_t *b_target;/* buffer target (device) */ -xfs_daddr_t b_bn;/* block number for I/O */ size_t b_count_desired;/* desired transfer size */ void *b_addr;/* virtual address of buffer */ struct work_struct b_iodone_work;
@@ -158,6 +164,11 @@ typedef struct xfs_buf {unsigned int b_page_count;/* size of page array */ unsigned int b_offset;/* page offset in first page */ unsigned short b_error;/* error code on I/O */ + +struct xfs_buf_vec *b_vec;/* compound buffer vector */ +struct xfs_buf_vec b_vec_array[XB_VECS ];/* inline vectors */ +int b_vec_count;/* size of vector array */ +#ifdef XFS_BUF_LOCK_TRACKING int b_last_holder;#endif
@@ -260,8 +271,8 @@ void xfs_buf_stale(struct xfs_buf *bp);#define XFS_BUF_UNWRITE (bp) ((bp)->b_flags &= ~XBF_WRITE)#define XFS_BUF_ISWRITE (bp) ((bp)->b_flags & XBF_WRITE) -#define XFS_BUF_ADDR (bp) ((bp)->b_bn) -#define XFS_BUF_SET_ADDR (bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) +#define XFS_BUF_ADDR (bp) ((bp)->b_vec[0].bv_bn) +#define XFS_BUF_SET_ADDR (bp, bno) ((bp)->b_vec[0].bv_bn = (xfs_daddr_t)(bno))#define XFS_BUF_OFFSET (bp) ((bp)->b_file_offset)#define XFS_BUF_SET_OFFSET (bp, off) ((bp)->b_file_offset = (off))#define XFS_BUF_COUNT (bp) ((bp)->b_count_desired)
fs/xfs/xfs_trace.h +4 -4
@@ -290,7 +290,7 @@ DECLARE_EVENT_CLASS(xfs_buf_class, ), TP_fast_assign( __entry->dev = bp->b_target->bt_dev; - __entry->bno = bp->b_bn; + __entry->bno = bp->b_vec[0 ].bv_bn; __entry->buffer_length = bp->b_buffer_length; __entry->hold =atomic_read (&bp->b_hold); __entry->pincount =atomic_read (&bp->b_pin_count);
@@ -361,7 +361,7 @@ DECLARE_EVENT_CLASS(xfs_buf_flags_class, ), TP_fast_assign( __entry->dev = bp->b_target->bt_dev; - __entry->bno = bp->b_bn; + __entry->bno = bp->b_vec[0 ].bv_bn; __entry->buffer_length = bp->b_buffer_length; __entry->flags = flags; __entry->hold =atomic_read (&bp->b_hold);
@@ -405,7 +405,7 @@ TRACE_EVENT(xfs_buf_ioerror, ), TP_fast_assign( __entry->dev = bp->b_target->bt_dev; - __entry->bno = bp->b_bn; + __entry->bno = bp->b_vec[0 ].bv_bn; __entry->buffer_length = bp->b_buffer_length; __entry->hold =atomic_read (&bp->b_hold); __entry->pincount =atomic_read (&bp->b_pin_count);
@@ -449,7 +449,7 @@ DECLARE_EVENT_CLASS(xfs_buf_item_class, __entry->bli_flags = bip->bli_flags; __entry->bli_recur = bip->bli_recur; __entry->bli_refcount =atomic_read (&bip->bli_refcount); - __entry->buf_bno = bip->bli_buf->b_bn; + __entry->buf_bno = bip->bli_buf->b_vec[0 ].bv_bn; __entry->buf_len = bip->bli_buf->b_buffer_length; __entry->buf_flags = bip->bli_buf->b_flags; __entry->buf_hold =atomic_read (&bip->bli_buf->b_hold);
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 8/12 xfs: support multiple irec maps in buffer code
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Add support for initialising and doing IO on multi-segment compound buffers.
--- fs/xfs/xfs_buf.c | 317 ++++++++++++++++++++++++++++++++++++++---------------- fs/xfs/xfs_buf.h | 7 +- 2 files changed, 228 insertions(+), 96 deletions(-)
fs/xfs/xfs_buf.c +225 -92
@@ -166,13 +166,15 @@ xfs_buf_stale( }struct xfs_buf * -xfs_buf_alloc ( +xfs_buf_alloc_irec (struct xfs_buftarg *target, -xfs_daddr_t blkno, -size_t numblks, +struct xfs_bmbt_irec *map, +int nmaps,xfs_buf_flags_t flags) { +xfs_daddr_t blkno;struct xfs_buf *bp; +int i; bp =kmem_zone_alloc (xfs_buf_zone,xb_to_km (flags));if (unlikely (!bp))
@@ -193,21 +195,45 @@ xfs_buf_alloc(sema_init (&bp->b_sema,0 );/* held, no waiters */ XB_SET_OWNER (bp); bp->b_target = target; - bp->b_file_offset = blkno <<BBSHIFT ; + bp->b_flags = flags; + +/* initialise the buffer IO vector array appropriately */ +if (nmaps <=XB_VECS ) { + bp->b_vec = &bp->b_vec_array[0 ]; + }else { + bp->b_vec =kmem_alloc (nmaps *sizeof (*bp->b_vec), +xb_to_km (flags)); +if (!bp->b_vec) { +kmem_zone_free (xfs_buf_zone, bp); +return NULL ; + } + } + bp->b_vec_count = nmaps; + bp->b_buffer_length =0 ; + +if (map[0 ].br_state ==XFS_EXT_DADDR ) + blkno = map[0 ].br_startblock; +else + blkno =XFS_FSB_TO_DADDR (target->bt_mount, map[0 ].br_startblock); + bp->b_file_offset =BBTOB (blkno); + +for (i =0 ; i < nmaps; i++) { +if (map[0 ].br_state ==XFS_EXT_DADDR ) { + bp->b_vec[i].bv_len +=BBTOB (map[i].br_blockcount); + }else { + bp->b_vec[i].bv_len +=XFS_FSB_TO_B (target->bt_mount, + map[i].br_blockcount); + } + bp->b_buffer_length += bp->b_vec[i].bv_len; + bp->b_vec[i].bv_bn =XFS_BUF_DADDR_NULL ; + } +/* * Set buffer_length and count_desired to the same value initially. * I/O routines should use count_desired, which will be the same in * most cases but may be reset (e.g. XFS recovery). */ - bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; - bp->b_flags = flags; - -/* XXX: we have the block number. Why don't we just set it here? */ -/* initialise the buffer IO vector array appropriately */ - bp->b_vec_count =1 ; - bp->b_vec = &bp->b_vec_array[0 ]; - bp->b_vec[0 ].bv_bn =XFS_BUF_DADDR_NULL ; - bp->b_vec[0 ].bv_len = bp->b_buffer_length; + bp->b_count_desired = bp->b_buffer_length;atomic_set (&bp->b_pin_count,0 );init_waitqueue_head (&bp->b_waiters);
@@ -218,6 +244,22 @@ xfs_buf_alloc(return bp; } +struct xfs_buf * +xfs_buf_alloc ( +struct xfs_buftarg *target, +xfs_daddr_t blkno, +size_t numblks, +xfs_buf_flags_t flags) +{ +struct xfs_bmbt_irec map = { + .br_startblock = blkno, + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; + +return xfs_buf_alloc_irec (target, &map,1 , flags); +} +/* * Allocate a page array capable of holding a specified number * of pages, and point the page buf at it.
@@ -287,6 +329,10 @@ xfs_buf_free( } }else if (bp->b_flags & _XBF_KMEM)kmem_free (bp->b_addr); + +if (bp->b_vec_count >XB_VECS ) +kmem_free (bp->b_vec); +_xfs_buf_free_pages (bp);kmem_zone_free (xfs_buf_zone, bp); }
@@ -429,11 +475,11 @@ _xfs_buf_map_pages(* a given range of an inode. The buffer is returned * locked. No I/O is implied by this call. */ -xfs_buf_t * -_xfs_buf_find ( +static xfs_buf_t * +xfs_buf_find_irec (xfs_buftarg_t *btp, -xfs_daddr_t blkno, -size_t numblks, +struct xfs_bmbt_irec *map, +int nmaps,xfs_buf_flags_t flags,xfs_buf_t *new_bp) {
@@ -442,14 +488,37 @@ _xfs_buf_find(struct xfs_perag *pag;struct rb_node **rbp;struct rb_node *parent; -xfs_buf_t *bp; +struct xfs_buf *bp; +xfs_daddr_t blkno; +int i; - offset = blkno <<BBSHIFT ; - numbytes = numblks <<BBSHIFT ; +/* +* Check for IOs smaller than the sector size or not sector aligned, +* calculate the size of the buffer and initialise variables that ggc +* thinks get unused without initialisation because it can't grok the +* fact they are initialised within the loop body. +*/ + numbytes =0 ; + offset =0 ; + blkno =XFS_BUF_DADDR_NULL ; +for (i =0 ; i < nmaps; i++) { +size_t len; + +if (map[0 ].br_state ==XFS_EXT_DADDR ) { + len =BBTOB (map[i].br_blockcount); + blkno = map[i].br_startblock; + }else { + len =XFS_FSB_TO_B (btp->bt_mount, map[i].br_blockcount); + blkno =XFS_FSB_TO_DADDR (btp->bt_mount, + map[i].br_startblock); + } +ASSERT (!(len < (1 << btp->bt_sshift))); +ASSERT (!(BBTOB (blkno) & (xfs_off_t )btp->bt_smask)); + numbytes += len; +if (i ==0 ) + offset =BBTOB (blkno); -/* Check for IOs smaller than the sector size / not sector aligned */ -ASSERT (!(numbytes < (1 << btp->bt_sshift))); -ASSERT (!(offset & (xfs_off_t )btp->bt_smask)); + }/* get tree root */ pag = xfs_perag_get(btp->bt_mount,
@@ -530,27 +599,6 @@ found:return bp; } -/* -* Assembles a buffer covering the specified range. The code is optimised for -* cache hits, as metadata intensive workloads will see 3 orders of magnitude -* more hits than misses. -*/ -struct xfs_buf * -xfs_buf_get ( -xfs_buftarg_t *target, -xfs_daddr_t blkno, -size_t numblks, -xfs_buf_flags_t flags) -{ -struct xfs_bmbt_irec map = { - .br_startblock = blkno, - .br_blockcount = numblks, - .br_state =XFS_EXT_DADDR , - }; - -return xfs_buf_get_irec (target, &map,1 , flags); -} - STATIC int _xfs_buf_read( xfs_buf_t *bp,
@@ -571,7 +619,9 @@ _xfs_buf_read( }/* -* XXX: only supports a single map for now +* Assembles a buffer covering the specified range. The code is optimised for +* cache hits, as metadata intensive workloads will see 3 orders of magnitude +* more hits than misses. */ struct xfs_buf * xfs_buf_get_irec(
@@ -580,31 +630,20 @@ xfs_buf_get_irec( int nmaps, xfs_buf_flags_t flags) { -xfs_daddr_t blkno; -size_t numblks;struct xfs_buf *bp;struct xfs_buf *new_bp;int error =0 ; +int i; -ASSERT_ALWAYS (nmaps ==1 ); - -if (map->br_state ==XFS_EXT_DADDR ) { - blkno = map->br_startblock; - numblks = map->br_blockcount; - }else { - blkno =XFS_FSB_TO_DADDR (target->bt_mount, map->br_startblock); - numblks =XFS_FSB_TO_BB (target->bt_mount, map->br_blockcount); - } - - bp =_xfs_buf_find (target, blkno, numblks, flags,NULL ); + bp =xfs_buf_find_irec (target, map, nmaps, flags,NULL );if (likely (bp)) goto found; - new_bp =xfs_buf_alloc (target, blkno, numblks, flags); + new_bp =xfs_buf_alloc_irec (target, map, nmaps, flags);if (unlikely (!new_bp))return NULL ; - bp =_xfs_buf_find (target, blkno, numblks, flags, new_bp); + bp =xfs_buf_find_irec (target, map, nmaps, flags, new_bp);if (!bp) {kmem_zone_free (xfs_buf_zone, new_bp);return NULL ;
@@ -618,11 +657,17 @@ xfs_buf_get_irec(kmem_zone_free (xfs_buf_zone, new_bp);/* -* Now we have a workable buffer, fill in the block number so -* that we can do IO on it. +* Now we have a workable buffer, fill in the block vector addresses +* so that we can do IO on it. The lengths have already been filled in +* by xfs_buf_alloc_irec(). */ - bp->b_vec[0 ].bv_bn = blkno; - bp->b_vec[0 ].bv_len = bp->b_buffer_length; +for (i =0 ; i < nmaps; i++) { +if (map[0 ].br_state ==XFS_EXT_DADDR ) + bp->b_vec[i].bv_bn = map[i].br_startblock; +else + bp->b_vec[i].bv_bn =XFS_FSB_TO_DADDR (target->bt_mount, + map[i].br_startblock); + } bp->b_count_desired = bp->b_buffer_length; found:
@@ -699,6 +744,39 @@ xfs_buf_readahead_irec( }xfs_buf_t * +xfs_buf_find ( +xfs_buftarg_t *target, +xfs_daddr_t blkno, +size_t numblks, +xfs_buf_flags_t flags) +{ +struct xfs_bmbt_irec map = { + .br_startblock = blkno, + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; + +return xfs_buf_find_irec (target, &map,1 , flags,NULL ); +} + +struct xfs_buf * +xfs_buf_get ( +xfs_buftarg_t *target, +xfs_daddr_t blkno, +size_t numblks, +xfs_buf_flags_t flags) +{ +struct xfs_bmbt_irec map = { + .br_startblock = blkno, + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; + +return xfs_buf_get_irec (target, &map,1 , flags); +} + + +xfs_buf_t * xfs_buf_read( xfs_buftarg_t *target, xfs_daddr_t blkno,
@@ -773,6 +851,8 @@ xfs_buf_set_empty( struct xfs_buf *bp, size_t numblks) { +ASSERT (bp->b_vec_count ==1 ); +if (bp->b_pages)_xfs_buf_free_pages (bp);
@@ -780,7 +860,7 @@ xfs_buf_set_empty( bp->b_page_count =0 ; bp->b_addr =NULL ; bp->b_file_offset =0 ; - bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; + bp->b_buffer_length = bp->b_count_desired =BBTOB (numblks); bp->b_vec[0 ].bv_bn =XFS_BUF_DADDR_NULL ; bp->b_vec[0 ].bv_len = bp->b_buffer_length; bp->b_flags &= ~XBF_MAPPED ;
@@ -849,12 +929,16 @@ xfs_buf_get_uncached(unsigned long page_count;int error, i;xfs_buf_t *bp; +struct xfs_bmbt_irec map = { + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; - bp =xfs_buf_alloc (target,0 , numblks,0 ); + bp =xfs_buf_alloc_irec (target, &map,1 ,0 );if (unlikely (bp ==NULL )) goto fail; - page_count =PAGE_ALIGN (numblks <<BBSHIFT ) >>PAGE_SHIFT ; + page_count =PAGE_ALIGN (BBTOB (numblks)) >>PAGE_SHIFT ; error =_xfs_buf_get_pages (bp, page_count,0 );if (error) goto fail_free_buf;
@@ -1248,36 +1332,38 @@ xfs_buf_bio_end_io(bio_put (bio); } -STATIC void -_xfs_buf_ioapply ( -xfs_buf_t *bp) +static void +_xfs_buf_ioapply_vec ( +struct xfs_buf *bp, +int vec, +int *buf_offset, +int *count, +int rw) { -int rw, map_i, total_nr_pages, nr_pages; +int map_i; +int total_nr_pages = bp->b_page_count; +int nr_pages;struct bio *bio; -int offset = bp->b_offset; -int size = bp->b_count_desired; -sector_t sector = bp->b_vec[0 ].bv_bn; +sector_t sector = bp->b_vec[vec].bv_bn; +int size; +int offset; total_nr_pages = bp->b_page_count; - map_i =0 ; -if (bp->b_flags &XBF_WRITE ) { -if (bp->b_flags &XBF_SYNCIO ) - rw =WRITE_SYNC ; -else - rw =WRITE ; -if (bp->b_flags &XBF_FUA ) - rw |=REQ_FUA ; -if (bp->b_flags &XBF_FLUSH ) - rw |=REQ_FLUSH ; - }else if (bp->b_flags &XBF_READ_AHEAD ) { - rw =READA ; - }else { - rw =READ ; +/* skip the pages in the buffer before the start offset */ + map_i =0 ; + offset = *buf_offset; +while (offset >=PAGE_SIZE ) { + map_i++; + offset -=PAGE_SIZE ; } -/* we only use the buffer cache for meta-data */ - rw |=REQ_META ; +/* +* Limit the IO size to the length of the current vector, and update the +* remaining IO count for the next time around. +*/ + size =min_t (int, bp->b_vec[vec].bv_len, *count); + *count -= size; next_chunk:atomic_inc (&bp->b_io_remaining);
@@ -1291,7 +1377,6 @@ next_chunk: bio->bi_end_io = xfs_buf_bio_end_io; bio->bi_private = bp; -for (; size && nr_pages; nr_pages--, map_i++) {int rbytes, nbytes =PAGE_SIZE - offset;
@@ -1303,7 +1388,7 @@ next_chunk:break ; offset =0 ; - sector += nbytes >>BBSHIFT ; + sector +=BTOBB (nbytes); size -= nbytes; total_nr_pages--; }
@@ -1320,8 +1405,56 @@ next_chunk:xfs_buf_ioerror (bp,EIO );bio_put (bio); } + +/* update the start offset for the next IO */ + *buf_offset += bp->b_vec[vec].bv_len; +} + +STATIC void +_xfs_buf_ioapply ( +struct xfs_buf *bp) +{ +int rw; +int offset; +int size; +int i; + +if (bp->b_flags &XBF_WRITE ) { +if (bp->b_flags &XBF_SYNCIO ) + rw =WRITE_SYNC ; +else + rw =WRITE ; +if (bp->b_flags &XBF_FUA ) + rw |=REQ_FUA ; +if (bp->b_flags &XBF_FLUSH ) + rw |=REQ_FLUSH ; + }else if (bp->b_flags &XBF_READ_AHEAD ) { + rw =READA ; + }else { + rw =READ ; + } + +/* we only use the buffer cache for meta-data */ + rw |=REQ_META ; + +/* +* Walk all the vectors issuing IO on them. Set up the initial offset +* into the buffer and the desired IO size before we start - +* _xfs_buf_ioapply_vec() will modify them appropriately for each +* subsequent call. +*/ + offset = bp->b_offset; + size = bp->b_count_desired; +for (i =0 ; i < bp->b_vec_count; i++) { +_xfs_buf_ioapply_vec (bp, i, &offset, &size, rw); +if (bp->b_error) +break ; +if (size <=0 ) +break ;/* all done */ + } } +int xfs_buf_iorequest (xfs_buf_t *bp)
fs/xfs/xfs_buf.h +3 -4
@@ -177,11 +177,10 @@ typedef struct xfs_buf {/* Finding and Reading Buffers */ -struct xfs_buf *_xfs_buf_find (struct xfs_buftarg *target,xfs_daddr_t blkno, -size_t numblks,xfs_buf_flags_t flags, -struct xfs_buf *new_bp); +struct xfs_buf *xfs_buf_find (struct xfs_buftarg *target,xfs_daddr_t blkno, +size_t numblks,xfs_buf_flags_t flags);#define xfs_incore (buftarg,blkno,len,lockit) \ - _xfs_buf_find(buftarg, blkno ,len, lockit, NULL) + xfs_buf_find(buftarg, blkno, len, lockit)struct xfs_buf *xfs_buf_get (struct xfs_buftarg *target,xfs_daddr_t blkno,size_t numblks,xfs_buf_flags_t flags);
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 10/12 xfs: use multiple irec xfs buf support in dabuf
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
--- fs/xfs/xfs_da_btree.c | 491 +++++++++++++++++++------------------------------ fs/xfs/xfs_da_btree.h | 6 +- 2 files changed, 191 insertions(+), 306 deletions(-)
fs/xfs/xfs_da_btree.c +190 -301
@@ -86,7 +86,7 @@ STATIC void xfs_da_node_unbalance(xfs_da_state_t *state,*/ STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count); STATIC int xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp); -STATIC xfs_dabuf_t *xfs_da_buf_make(int nbuf, xfs_buf_t **bps); +STATIC xfs_dabuf_t *xfs_da_buf_make(xfs_buf_t *bp); STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,xfs_da_state_blk_t *drop_blk,xfs_da_state_blk_t *save_blk);
@@ -1936,35 +1936,32 @@ xfs_da_map_covers_blocks( }/* -* Make a dabuf. -* Used for get_buf, read_buf, read_bufr, and reada_buf. +* Map the block we are given ready for reading. There are three possible return +* values: +* -1 - will be returned if we land in a hole and mappedbno == -2 so the +* caller knows not to execute a subsequent read. +* 0 - if we mapped the block successfully +* >0 - positive error number if there was an error. */ -STATIC int -xfs_da_do_buf ( -xfs_trans_t *trans, -xfs_inode_t *dp, -xfs_dablk_t bno, -xfs_daddr_t *mappedbnop, -xfs_dabuf_t **bpp, -int whichfork, -int caller) +static int +xfs_dabuf_map ( +struct xfs_trans *trans, +struct xfs_inode *dp, +xfs_dablk_t bno, +xfs_daddr_t mappedbno, +int whichfork, +struct xfs_bmbt_irec **map, +int *nmaps) { -xfs_buf_t *bp =NULL ; -xfs_buf_t **bplist; -int error=0 ; -int i; -xfs_bmbt_irec_t map; -xfs_bmbt_irec_t *mapp; -xfs_daddr_t mappedbno; -xfs_mount_t *mp; -int nbplist=0 ; -int nfsb; -int nmap; -xfs_dabuf_t *rbp; +struct xfs_mount *mp = dp->i_mount; +int nfsb; +int error; + +ASSERT (map && *map); +ASSERT (*nmaps ==1 ); - mp = dp->i_mount; nfsb = (whichfork ==XFS_DATA_FORK ) ? mp->m_dirblkfsbs :1 ; - mappedbno = *mappedbnop; +/* * Caller doesn't have a mapping. -2 means don't complain * if we land in a hole.
@@ -1973,114 +1970,147 @@ xfs_da_do_buf(/* * Optimize the one-block case. */ -if (nfsb ==1 ) - mapp = ↦ -else - mapp =kmem_alloc (sizeof (*mapp) * nfsb,KM_SLEEP ); +if (nfsb !=1 ) + *map =kmem_zalloc (sizeof (**map) * nfsb,KM_SLEEP ); - nmap = nfsb; - error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, mapp, - &nmap,xfs_bmapi_aflag (whichfork)); + *nmaps = nfsb; + error =xfs_bmapi_read (dp, (xfs_fileoff_t )bno, nfsb, *map, + nmaps,xfs_bmapi_aflag (whichfork));if (error) - goto exit0; +return error; }else { - map.br_startblock =XFS_DADDR_TO_FSB (mp, mappedbno); - map.br_startoff = (xfs_fileoff_t )bno; - map.br_blockcount = nfsb; - mapp = ↦ - nmap =1 ; + (*map)->br_startblock =XFS_DADDR_TO_FSB (mp, mappedbno); + (*map)->br_startoff = (xfs_fileoff_t )bno; + (*map)->br_blockcount = nfsb; + (*map)->br_state =0 ; } -if (!xfs_da_map_covers_blocks (nmap, mapp, bno, nfsb)) { - error = mappedbno ==-2 ?0 :XFS_ERROR (EFSCORRUPTED ); + +if (!xfs_da_map_covers_blocks (*nmaps, *map, bno, nfsb)) { + error = mappedbno ==-2 ?-1 :XFS_ERROR (EFSCORRUPTED );if (unlikely (error ==EFSCORRUPTED )) {if (xfs_error_level >=XFS_ERRLEVEL_LOW ) { +int i;xfs_alert (mp,"%s: bno %lld dir: inode %lld" , __func__, (long long )bno, (long long )dp->i_ino); -for (i =0 ; i < nmap; i++) { +for (i =0 ; i < *nmaps; i++) {xfs_alert (mp,"[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d" , i, - (long long )mapp[i].br_startoff, - (long long )mapp[i].br_startblock, - (long long )mapp[i].br_blockcount, - mapp[i].br_state); + (long long )(*map)[i].br_startoff, + (long long )(*map)[i].br_startblock, + (long long )(*map)[i].br_blockcount, + (*map)[i].br_state); } }XFS_ERROR_REPORT ("xfs_da_do_buf(1)" ,XFS_ERRLEVEL_LOW , mp); } - goto exit0; +return error; } -if (caller !=3 && nmap >1 ) { - bplist =kmem_alloc (sizeof (*bplist) * nmap,KM_SLEEP ); - nbplist =0 ; - }else - bplist =NULL ; -/* -* Turn the mapping(s) into buffer(s). -*/ -for (i =0 ; i < nmap; i++) { -int nmapped; - - mappedbno =XFS_FSB_TO_DADDR (mp, mapp[i].br_startblock); -if (i ==0 ) - *mappedbnop =XFS_FSB_TO_DADDR (mp, - mapp[i].br_startblock); - nmapped = (int )XFS_FSB_TO_BB (mp, mapp[i].br_blockcount); -switch (caller) { -case 0 : - bp =xfs_trans_get_buf_irec (trans, mp->m_ddev_targp, - &mapp[i],1 ,0 ); - error = bp ? bp->b_error :XFS_ERROR (EIO ); -break ; -case 1 : -case 2 : - bp =NULL ; - error =xfs_trans_read_buf_irec (mp, trans, - mp->m_ddev_targp, &mapp[i],1 , -0 , &bp); -break ; -case 3 : -xfs_buf_readahead_irec (mp->m_ddev_targp, &mapp[i],1 ); +return 0 ; +} + +/* +* Get a buffer for the dir/attr block. +*/ +int +xfs_da_get_buf ( +struct xfs_trans *trans, +struct xfs_inode *dp, +xfs_dablk_t bno, +xfs_daddr_t mappedbno, +xfs_dabuf_t **bpp, +int whichfork) +{ +struct xfs_buf *bp; +struct xfs_bmbt_irec map; +struct xfs_bmbt_irec *mapp; +int nmap; +int error; + + *bpp =NULL ; + mapp = ↦ + nmap =1 ; + error =xfs_dabuf_map (trans, dp, bno, mappedbno, whichfork, + &mapp, &nmap); +if (error) { +/* mapping a hole is not an error, but we don't continue */ +if (error ==-1 ) error =0 ; - bp =NULL ; -break ; - } -if (error) { -if (bp) -xfs_trans_brelse (trans, bp); - goto exit1; - } -if (!bp) -continue ; -if (caller ==1 ) { -if (whichfork ==XFS_ATTR_FORK ) -xfs_buf_set_ref (bp,XFS_ATTR_BTREE_REF ); -else -xfs_buf_set_ref (bp,XFS_DIR_BTREE_REF ); - } -if (bplist) { - bplist[nbplist++] = bp; - } + goto out_free; } -/* -* Build a dabuf structure. -*/ -if (bplist) { - rbp =xfs_da_buf_make (nbplist, bplist); - }else if (bp) - rbp =xfs_da_buf_make (1 , &bp); + + bp =xfs_trans_get_buf_irec (trans, dp->i_mount->m_ddev_targp, + mapp, nmap,0 ); + error = bp ? bp->b_error :XFS_ERROR (EIO ); +if (error) { +xfs_trans_brelse (trans, bp); + goto out_free; + } + + *bpp =xfs_da_buf_make (bp); + +out_free: +if (mapp != &map) +kmem_free (mapp); + +return error; +} + +/* +* Get a buffer for the dir/attr block, fill in the contents. +*/ +int +xfs_da_read_buf ( +struct xfs_trans *trans, +struct xfs_inode *dp, +xfs_dablk_t bno, +xfs_daddr_t mappedbno, +xfs_dabuf_t **bpp, +int whichfork) +{ +struct xfs_buf *bp; +struct xfs_bmbt_irec map; +struct xfs_bmbt_irec *mapp; +int nmap; +int error; + + *bpp =NULL ; + mapp = ↦ + nmap =1 ; + error =xfs_dabuf_map (trans, dp, bno, mappedbno, whichfork, + &mapp, &nmap); +if (error) { +/* mapping a hole is not an error, but we don't continue */ +if (error ==-1 ) + error =0 ; + goto out_free; + } + + error =xfs_trans_read_buf_irec (dp->i_mount, trans, + dp->i_mount->m_ddev_targp, + mapp, nmap,0 , &bp); +if (error) + goto out_free; + +if (whichfork ==XFS_ATTR_FORK ) +xfs_buf_set_ref (bp,XFS_ATTR_BTREE_REF );else - rbp =NULL ; +xfs_buf_set_ref (bp,XFS_DIR_BTREE_REF ); + + *bpp =xfs_da_buf_make (bp); +/* -* For read_buf, check the magic number. +* This verification code will be moved to a CRC verification callback +* function so just leave it here unchanged until then. */ -if (caller ==1 ) { -xfs_dir2_data_hdr_t *hdr = rbp->data; -xfs_dir2_free_t *free = rbp->data; -xfs_da_blkinfo_t *info = rbp->data; + { +xfs_dir2_data_hdr_t *hdr = (*bpp)->data; +xfs_dir2_free_t *free = (*bpp)->data; +xfs_da_blkinfo_t *info = (*bpp)->data;uint magic, magic1; +struct xfs_mount *mp = dp->i_mount; magic =be16_to_cpu (info->magic); magic1 =be32_to_cpu (hdr->magic);
@@ -2094,66 +2124,20 @@ xfs_da_do_buf( (free->hdr.magic != cpu_to_be32(XFS_DIR2_FREE_MAGIC)), mp, XFS_ERRTAG_DA_READ_BUF, XFS_RANDOM_DA_READ_BUF))) { -trace_xfs_da_btree_corrupt (rbp->bps[0 ], _RET_IP_); +trace_xfs_da_btree_corrupt (bp, _RET_IP_);XFS_CORRUPTION_ERROR ("xfs_da_do_buf(2)" ,XFS_ERRLEVEL_LOW , mp, info); error =XFS_ERROR (EFSCORRUPTED ); -xfs_da_brelse (trans, rbp); - nbplist =0 ; - goto exit1; +xfs_da_brelse (trans, *bpp); + goto out_free; } } -if (bplist) { -kmem_free (bplist); - } -if (mapp != &map) { -kmem_free (mapp); - } -if (bpp) - *bpp = rbp; -return 0 ; -exit1: -if (bplist) { -for (i =0 ; i < nbplist; i++) -xfs_trans_brelse (trans, bplist[i]); -kmem_free (bplist); - } -exit0: + +out_free:if (mapp != &map)kmem_free (mapp); -if (bpp) - *bpp =NULL ; -return error; -} - -/* -* Get a buffer for the dir/attr block. -*/ -int -xfs_da_get_buf ( -xfs_trans_t *trans, -xfs_inode_t *dp, -xfs_dablk_t bno, -xfs_daddr_t mappedbno, -xfs_dabuf_t **bpp, -int whichfork) -{ -return xfs_da_do_buf (trans, dp, bno, &mappedbno, bpp, whichfork,0 ); -} -/* -* Get a buffer for the dir/attr block, fill in the contents. -*/ -int -xfs_da_read_buf ( -xfs_trans_t *trans, -xfs_inode_t *dp, -xfs_dablk_t bno, -xfs_daddr_t mappedbno, -xfs_dabuf_t **bpp, -int whichfork) -{ -return xfs_da_do_buf (trans, dp, bno, &mappedbno, bpp, whichfork,1 ); +return error; }/*
@@ -2161,18 +2145,38 @@ xfs_da_read_buf(*/ xfs_daddr_t xfs_da_reada_buf ( -xfs_trans_t *trans, -xfs_inode_t *dp, -xfs_dablk_t bno, -int whichfork) +struct xfs_trans *trans, +struct xfs_inode *dp, +xfs_dablk_t bno, +int whichfork) { -xfs_daddr_t rval; +xfs_daddr_t mappedbno =-1 ; +struct xfs_bmbt_irec map; +struct xfs_bmbt_irec *mapp; +int nmap; +int error; - rval =-1 ; -if (xfs_da_do_buf (trans, dp, bno, &rval,NULL , whichfork,3 )) + mapp = ↦ + nmap =1 ; + error =xfs_dabuf_map (trans, dp, bno,-1 , whichfork, + &mapp, &nmap); +if (error) { +/* mapping a hole is not an error, but we don't continue */ +if (error ==-1 ) + error =0 ; + goto out_free; + } + + mappedbno =XFS_FSB_TO_DADDR (dp->i_mount, mapp[0 ].br_startblock); +xfs_buf_readahead_irec (dp->i_mount->m_ddev_targp, mapp, nmap); + +out_free: +if (mapp != &map) +kmem_free (mapp); + +if (error)return -1 ; -else -return rval; +return mappedbno; }kmem_zone_t *xfs_da_state_zone;/* anchor for state struct zone */
@@ -2232,78 +2236,26 @@ xfs_da_state_free(xfs_da_state_t *state)*/ /* ARGSUSED */ STATIC xfs_dabuf_t * -xfs_da_buf_make (int nbuf,xfs_buf_t **bps) +xfs_da_buf_make (xfs_buf_t *bp) { -xfs_buf_t *bp;xfs_dabuf_t *dabuf; -int i; -int off; -if (nbuf ==1 ) - dabuf =kmem_zone_alloc (xfs_dabuf_zone,KM_NOFS ); -else - dabuf =kmem_alloc (XFS_DA_BUF_SIZE (nbuf),KM_NOFS ); - dabuf->dirty =0 ; -if (nbuf ==1 ) { - dabuf->nbuf =1 ; - bp = bps[0 ]; - dabuf->bbcount = (short )BTOBB (XFS_BUF_COUNT (bp)); - dabuf->data = bp->b_addr; - dabuf->bps[0 ] = bp; - }else { - dabuf->nbuf = nbuf; -for (i =0 , dabuf->bbcount =0 ; i < nbuf; i++) { - dabuf->bps[i] = bp = bps[i]; - dabuf->bbcount +=BTOBB (XFS_BUF_COUNT (bp)); - } - dabuf->data =kmem_alloc (BBTOB (dabuf->bbcount),KM_SLEEP ); -for (i = off =0 ; i < nbuf; i++, off +=XFS_BUF_COUNT (bp)) { - bp = bps[i]; -memcpy ((char *)dabuf->data + off, bp->b_addr, -XFS_BUF_COUNT (bp)); - } - } + dabuf =kmem_zone_alloc (xfs_dabuf_zone,KM_NOFS ); + dabuf->bbcount = (short )BTOBB (XFS_BUF_COUNT (bp)); + dabuf->data = bp->b_addr; + dabuf->bp = bp;return dabuf; }/* -* Un-dirty a dabuf. -*/ -STATIC void -xfs_da_buf_clean (xfs_dabuf_t *dabuf) -{ -xfs_buf_t *bp; -int i; -int off; - -if (dabuf->dirty) { -ASSERT (dabuf->nbuf >1 ); - dabuf->dirty =0 ; -for (i = off =0 ; i < dabuf->nbuf; - i++, off +=XFS_BUF_COUNT (bp)) { - bp = dabuf->bps[i]; -memcpy (bp->b_addr, dabuf->data + off, -XFS_BUF_COUNT (bp)); - } - } -} - -/* * Release a dabuf. */ void xfs_da_buf_done (xfs_dabuf_t *dabuf) {ASSERT (dabuf); -ASSERT (dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0 ]); -if (dabuf->dirty) -xfs_da_buf_clean (dabuf); -if (dabuf->nbuf >1 ) { -kmem_free (dabuf->data); -kmem_free (dabuf); - }else { -kmem_zone_free (xfs_dabuf_zone, dabuf); - } +ASSERT (dabuf->data && dabuf->bbcount && dabuf->bp); +kmem_zone_free (xfs_dabuf_zone, dabuf); }/*
@@ -2312,41 +2264,9 @@ xfs_da_buf_done(xfs_dabuf_t *dabuf)void xfs_da_log_buf (xfs_trans_t *tp,xfs_dabuf_t *dabuf,uint first,uint last) { -xfs_buf_t *bp; -uint f; -int i; -uint l; -int off; - -ASSERT (dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0 ]); -if (dabuf->nbuf ==1 ) { -ASSERT (dabuf->data == dabuf->bps[0 ]->b_addr); -xfs_trans_log_buf (tp, dabuf->bps[0 ], first, last); -return ; - } - dabuf->dirty =1 ; -ASSERT (first <= last); -for (i = off =0 ; i < dabuf->nbuf; i++, off +=XFS_BUF_COUNT (bp)) { - bp = dabuf->bps[i]; - f = off; - l = f +XFS_BUF_COUNT (bp) -1 ; -if (f < first) - f = first; -if (l > last) - l = last; -if (f <= l) -xfs_trans_log_buf (tp, bp, f - off, l - off); -/* -* B_DONE is set by xfs_trans_log buf. -* If we don't set it on a new buffer (get not read) -* then if we don't put anything in the buffer it won't -* be set, and at commit it it released into the cache, -* and then a read will fail. -*/ -else if (!(XFS_BUF_ISDONE (bp))) -XFS_BUF_DONE (bp); - } -ASSERT (last < off); +ASSERT (dabuf->data && dabuf->bbcount && dabuf->bp); +ASSERT (dabuf->data == dabuf->bp->b_addr); +xfs_trans_log_buf (tp, dabuf->bp, first, last); }/*
@@ -2357,24 +2277,9 @@ xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last)void xfs_da_brelse (xfs_trans_t *tp,xfs_dabuf_t *dabuf) { -xfs_buf_t *bp; -xfs_buf_t **bplist; -int i; -int nbuf; - -ASSERT (dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0 ]); -if ((nbuf = dabuf->nbuf) ==1 ) { - bplist = &bp; - bp = dabuf->bps[0 ]; - }else { - bplist =kmem_alloc (nbuf *sizeof (*bplist),KM_SLEEP ); -memcpy (bplist, dabuf->bps, nbuf *sizeof (*bplist)); - } +ASSERT (dabuf->data && dabuf->bbcount && dabuf->bp); +xfs_trans_brelse (tp, dabuf->bp);xfs_da_buf_done (dabuf); -for (i =0 ; i < nbuf; i++) -xfs_trans_brelse (tp, bplist[i]); -if (bplist != &bp) -kmem_free (bplist); }/*
@@ -2383,24 +2288,9 @@ xfs_da_brelse(xfs_trans_t *tp, xfs_dabuf_t *dabuf)void xfs_da_binval (xfs_trans_t *tp,xfs_dabuf_t *dabuf) { -xfs_buf_t *bp; -xfs_buf_t **bplist; -int i; -int nbuf; - -ASSERT (dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0 ]); -if ((nbuf = dabuf->nbuf) ==1 ) { - bplist = &bp; - bp = dabuf->bps[0 ]; - }else { - bplist =kmem_alloc (nbuf *sizeof (*bplist),KM_SLEEP ); -memcpy (bplist, dabuf->bps, nbuf *sizeof (*bplist)); - } +ASSERT (dabuf->data && dabuf->bbcount && dabuf->bp);xfs_da_buf_done (dabuf); -for (i =0 ; i < nbuf; i++) -xfs_trans_binval (tp, bplist[i]); -if (bplist != &bp) -kmem_free (bplist); +xfs_trans_binval (tp, dabuf->bp); }/*
@@ -2409,7 +2299,6 @@ xfs_da_binval(xfs_trans_t *tp, xfs_dabuf_t *dabuf)xfs_daddr_t xfs_da_blkno (xfs_dabuf_t *dabuf) { -ASSERT (dabuf->nbuf);ASSERT (dabuf->data); -return XFS_BUF_ADDR (dabuf->bps[0 ]); +return XFS_BUF_ADDR (dabuf->bp); }
fs/xfs/xfs_da_btree.h +1 -5
@@ -141,14 +141,10 @@ typedef struct xfs_da_args {* same place as the b_addr field for the buffer, else to kmem_alloced memory. */ typedef struct xfs_dabuf { -int nbuf;/* number of buffer pointers present */ -short dirty;/* data needs to be copied back */ short bbcount;/* how large is data in bbs */ void *data;/* pointer for buffers' data */ -struct xfs_buf *bps[1 ];/* actually nbuf of these */ +struct xfs_buf *bp;/* actually nbuf of these */ }xfs_dabuf_t ; -#define XFS_DA_BUF_SIZE (n) \ - (sizeof(xfs_dabuf_t) + sizeof(struct xfs_buf *) * ((n) - 1))/* * Storage for holding state during Btree searches and split/join ops.
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 7/12 xfs: switch the buffer get/read API to use irec methods
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Before implementing multiple irec support, switch the non-irec interface to use the irec interface internally. This allows the buffer initialisation code to be swtiched to an irec interface to enable multiple irec buffers to be implemented without duplicating lots of code.
To be able to support sub-fsb addressed blocks (various AG headers) add a special in-memory only state flag to the xfs_bmbt_irec structure to allow the structure to hold different unit types. If no flag is set, the unit type if FSB (as used everywhere right now). Internally to the buffer cache the XFS_EXT_DADDR flag is used to indicate the bmbt_irec values are in disk address format rather than FSB to allow sub-FSB block support.
--- fs/xfs/xfs_bmap_btree.h | 6 ++- fs/xfs/xfs_buf.c | 182 ++++++++++++++++++++++------------------------- 2 files changed, 89 insertions(+), 99 deletions(-)
fs/xfs/xfs_bmap_btree.h +5 -1
@@ -99,10 +99,14 @@ typedef enum {/* * Possible extent states. +* +* XFS_EXT_DADDR does not exist on disk - it is only used in memory to indicate +* that the contents of the bmbt_irec are in daddr units, not fsb units. */ typedef enum {XFS_EXT_NORM ,XFS_EXT_UNWRITTEN , -XFS_EXT_DMAPI_OFFLINE ,XFS_EXT_INVALID +XFS_EXT_DMAPI_OFFLINE ,XFS_EXT_INVALID , +XFS_EXT_DADDR , }xfs_exntst_t ;/*
fs/xfs/xfs_buf.c +84 -98
227 lines not on this page · raw message
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 9/12 xfs: support compund buffers in buf_item logging
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Quoted 1 line
From the perspective of the log, we need to keep each segment of a
compound buffer in separate buffer format structures. This means log recovery will recover all the changes on a per segment basis without requiring any knowledge of the fact that it was logged from a compound buffer.
To do this, we need to be able to determine what buffer segment any given offset into the compound buffer sits over. This enables us to translate the dirty bitmap in the number of separate buffer format structures required.
We also need to be able to determine the number of bitmap elements that a given buffer segment has, as this determines the size of the buffer format structure. Hence we need to be able to determine the both the start offset into the buffer and the length of a given segment to be able to calculate this.
With this information, we can preallocate, build and format the correct log vector array for each segment in a compound buffer to appear exactly the same as individually logged buffers in the log.
--- fs/xfs/xfs_buf_item.c | 352 +++++++++++++++++++++++++++++++++++-------------- fs/xfs/xfs_buf_item.h | 6 +- 2 files changed, 255 insertions(+), 103 deletions(-)
fs/xfs/xfs_buf_item.c +250 -102
@@ -143,44 +143,26 @@ xfs_buf_item_log_check( STATIC void xfs_buf_do_callbacks(struct xfs_buf *bp); -/* -* This returns the number of log iovecs needed to log the -* given buf log item. -* -* It calculates this as 1 iovec for the buf log format structure -* and 1 for each stretch of non-contiguous chunks to be logged. -* Contiguous chunks are logged in a single iovec. -* -* If the XFS_BLI_STALE flag has been set, then log nothing. -*/ STATIC uint -xfs_buf_item_size ( -struct xfs_log_item *lip) +xfs_buf_item_size_segment ( +struct xfs_buf_log_item *bip, +struct xfs_buf_log_format *blfp) { -struct xfs_buf_log_item *bip =BUF_ITEM (lip);struct xfs_buf *bp = bip->bli_buf;uint nvecs;int next_bit;int last_bit; -ASSERT (atomic_read (&bip->bli_refcount) >0 ); -if (bip->bli_flags &XFS_BLI_STALE ) { -/* -* The buffer is stale, so all we need to log -* is the buf log format structure with the -* cancel flag in it. -*/ -trace_xfs_buf_item_size_stale (bip); -ASSERT (bip->bli_format.blf_flags &XFS_BLF_CANCEL ); -return 1 ; - } + last_bit =xfs_next_bit (blfp->blf_data_map, blfp->blf_map_size,0 ); +if (last_bit ==-1 ) +return 0 ; + +/* +* initial count for a dirty buffer is 2 vectors - the format structure +* and the first dirty region. +*/ + nvecs =2 ; -ASSERT (bip->bli_flags &XFS_BLI_LOGGED ); - nvecs =1 ; - last_bit =xfs_next_bit (bip->bli_format.blf_data_map, - bip->bli_format.blf_map_size,0 ); -ASSERT (last_bit !=-1 ); - nvecs++;while (last_bit !=-1 ) {/* * This takes the bit number to start looking from and
@@ -188,8 +170,7 @@ xfs_buf_item_size(* if there are no more bits set or the start bit is * beyond the end of the bitmap. */ - next_bit =xfs_next_bit (bip->bli_format.blf_data_map, - bip->bli_format.blf_map_size, + next_bit =xfs_next_bit (blfp->blf_data_map, blfp->blf_map_size, last_bit +1 );/* * If we run out of bits, leave the loop,
@@ -197,7 +178,7 @@ xfs_buf_item_size(* else keep scanning the current set of bits. */ if (next_bit ==-1 ) { - last_bit =-1 ; +break ; }else if (next_bit != last_bit +1 ) { last_bit = next_bit; nvecs++;
@@ -211,22 +192,80 @@ xfs_buf_item_size( } } -trace_xfs_buf_item_size (bip);return nvecs; }/* -* This is called to fill in the vector of log iovecs for the -* given log buf item. It fills the first entry with a buf log -* format structure, and the rest point to contiguous chunks -* within the buffer. +* This returns the number of log iovecs needed to log the +* given buf log item. +* +* It calculates this as 1 iovec for the buf log format structure +* and 1 for each stretch of non-contiguous chunks to be logged. +* Contiguous chunks are logged in a single iovec. +* +* Compound buffers need a buf log format structure per vector that that is +* being logged. This makes the changes in the compound buffer appear to log +* recovery as though they came from separate buffers, just like would occur if +* multiple buffers were used instead of a compound buffer. This enables +* compound buffers to be in-memory constructs, completely transparent to what +* ends up on disk. +* +* If the XFS_BLI_STALE flag has been set, then log nothing but the buf log +* format structures. */ -STATIC void -xfs_buf_item_format ( -struct xfs_log_item *lip, -struct xfs_log_iovec *vecp) +STATIC uint +xfs_buf_item_size ( +struct xfs_log_item *lip) {struct xfs_buf_log_item *bip =BUF_ITEM (lip); +uint nvecs; + +ASSERT (atomic_read (&bip->bli_refcount) >0 ); +if (bip->bli_flags &XFS_BLI_STALE ) { +/* +* The buffer is stale, so all we need to log +* is the buf log format structure with the +* cancel flag in it. +*/ +trace_xfs_buf_item_size_stale (bip); +ASSERT (bip->bli_format.blf_flags &XFS_BLF_CANCEL ); +return bip->bli_format_count; + } + +ASSERT (bip->bli_flags &XFS_BLI_LOGGED ); + +/* +* the vector count is based on the number of buffer vectors we have +* dirty bits in. This will only be greater than one when we have a +* compound buffer with more than one segment dirty. Hence for compound +* buffers we need to track which segment the dirty bits correspond to, +* and when we move from one segment to the next increment the vector +* count for the extra buf log format structure that will need to be +* written. +*/ +if (bip->bli_format_count ==1 ) { + nvecs =xfs_buf_item_size_segment (bip, &bip->bli_format); + }else { +int i; + + nvecs =0 ; +for (i =0 ; i < bip->bli_format_count; i++) { + nvecs +=xfs_buf_item_size_segment (bip, + bip->bli_formatp[i]); + } + } + +trace_xfs_buf_item_size (bip); +return nvecs; +} + +static struct xfs_log_iovec * +xfs_buf_item_format_segment ( +struct xfs_buf_log_item *bip, +struct xfs_log_iovec *vecp, +uint offset, +struct xfs_buf_log_format *blfp) +{struct xfs_buf *bp = bip->bli_buf;uint base_size;uint nvecs;
@@ -236,38 +275,28 @@ xfs_buf_item_format(uint nbits;uint buffer_offset; -ASSERT (atomic_read (&bip->bli_refcount) >0 ); -ASSERT ((bip->bli_flags &XFS_BLI_LOGGED ) || - (bip->bli_flags &XFS_BLI_STALE )); +/* copy the flags across from the base format item */ + blfp->blf_flags = bip->bli_format.blf_flags; -/* -* The size of the base structure is the size of the -* declared structure plus the space for the extra words -* of the bitmap. We subtract one from the map size, because -* the first element of the bitmap is accounted for in the -* size of the base structure. -*/ - base_size = - (uint)(sizeof (xfs_buf_log_format_t) + - ((bip->bli_format.blf_map_size -1 ) *sizeof (uint))); - vecp->i_addr = &bip->bli_format; + base_size = (uint)(sizeof (xfs_buf_log_format_t) + + ((blfp->blf_map_size -1 ) *sizeof (uint))); + vecp->i_addr = blfp; vecp->i_len = base_size; vecp->i_type =XLOG_REG_TYPE_BFORMAT ; vecp++; nvecs =1 ;/* -* If it is an inode buffer, transfer the in-memory state to the -* format flags and clear the in-memory state. We do not transfer +* If it is an inode buffer, transfer the in-memory state to the format +* flags. The in-memory state gets cleared later. We do not transfer * this state if the inode buffer allocation has not yet been committed -* to the log as setting the XFS_BLI_INODE_BUF flag will prevent -* correct replay of the inode allocation. +* to the log as setting the XFS_BLI_INODE_BUF flag will prevent correct +* replay of the inode allocation. */ if (bip->bli_flags &XFS_BLI_INODE_BUF ) {if (!((bip->bli_flags &XFS_BLI_INODE_ALLOC_BUF ) && -xfs_log_item_in_current_chkpt (lip))) - bip->bli_format.blf_flags |=XFS_BLF_INODE_BUF ; - bip->bli_flags &= ~XFS_BLI_INODE_BUF ; +xfs_log_item_in_current_chkpt (&bip->bli_item))) + blfp->blf_flags |=XFS_BLF_INODE_BUF ; }if (bip->bli_flags &XFS_BLI_STALE ) {
@@ -277,16 +306,15 @@ xfs_buf_item_format(* cancel flag in it. */ trace_xfs_buf_item_format_stale (bip); -ASSERT (bip->bli_format.blf_flags &XFS_BLF_CANCEL ); - bip->bli_format.blf_size = nvecs; -return ; +ASSERT (blfp->blf_flags &XFS_BLF_CANCEL ); + blfp->blf_size = nvecs; +return vecp; }/* * Fill in an iovec for each set of contiguous chunks. */ - first_bit =xfs_next_bit (bip->bli_format.blf_data_map, - bip->bli_format.blf_map_size,0 ); + first_bit =xfs_next_bit (blfp->blf_data_map, blfp->blf_map_size,0 );ASSERT (first_bit !=-1 ); last_bit = first_bit; nbits =1 ;
@@ -297,8 +325,7 @@ xfs_buf_item_format(* if there are no more bits set or the start bit is * beyond the end of the bitmap. */ - next_bit =xfs_next_bit (bip->bli_format.blf_data_map, - bip->bli_format.blf_map_size, + next_bit =xfs_next_bit (blfp->blf_data_map, blfp->blf_map_size, (uint )last_bit +1 );/* * If we run out of bits fill in the last iovec and get
@@ -310,14 +337,14 @@ xfs_buf_item_format(* keep counting and scanning. */ if (next_bit ==-1 ) { - buffer_offset = first_bit *XFS_BLF_CHUNK ; + buffer_offset = offset + first_bit *XFS_BLF_CHUNK ; vecp->i_addr =xfs_buf_offset (bp, buffer_offset); vecp->i_len = nbits *XFS_BLF_CHUNK ; vecp->i_type =XLOG_REG_TYPE_BCHUNK ; nvecs++;break ; }else if (next_bit != last_bit +1 ) { - buffer_offset = first_bit *XFS_BLF_CHUNK ; + buffer_offset = offset + first_bit *XFS_BLF_CHUNK ; vecp->i_addr =xfs_buf_offset (bp, buffer_offset); vecp->i_len = nbits *XFS_BLF_CHUNK ; vecp->i_type =XLOG_REG_TYPE_BCHUNK ;
@@ -326,10 +353,10 @@ xfs_buf_item_format( first_bit = next_bit; last_bit = next_bit; nbits =1 ; - }else if (xfs_buf_offset (bp, next_bit <<XFS_BLF_SHIFT ) != - (xfs_buf_offset (bp, last_bit <<XFS_BLF_SHIFT ) + + }else if (xfs_buf_offset (bp, offset + (next_bit <<XFS_BLF_SHIFT )) != + (xfs_buf_offset (bp, offset + (last_bit <<XFS_BLF_SHIFT )) +XFS_BLF_CHUNK )) { - buffer_offset = first_bit *XFS_BLF_CHUNK ; + buffer_offset = offset + first_bit *XFS_BLF_CHUNK ; vecp->i_addr =xfs_buf_offset (bp, buffer_offset); vecp->i_len = nbits *XFS_BLF_CHUNK ; vecp->i_type =XLOG_REG_TYPE_BCHUNK ;
@@ -348,6 +375,49 @@ xfs_buf_item_format( } } bip->bli_format.blf_size = nvecs; +return vecp; +} + +/* +* This is called to fill in the vector of log iovecs for the +* given log buf item. It fills the first entry with a buf log +* format structure, and the rest point to contiguous chunks +* within the buffer. +*/ +STATIC void +xfs_buf_item_format ( +struct xfs_log_item *lip, +struct xfs_log_iovec *vecp) +{ +struct xfs_buf_log_item *bip =BUF_ITEM (lip); +struct xfs_buf *bp = bip->bli_buf; + +ASSERT (atomic_read (&bip->bli_refcount) >0 ); +ASSERT ((bip->bli_flags &XFS_BLI_LOGGED ) || + (bip->bli_flags &XFS_BLI_STALE )); + +/* +* The size of the base structure is the size of the declared structure +* plus the space for the extra words of the bitmap. We subtract one +* from the map size, because the first element of the bitmap is +* accounted for in the size of the base structure. +*/ +if (bip->bli_format_count ==1 ) { + vecp =xfs_buf_item_format_segment (bip, vecp,0 , + &bip->bli_format); + }else { +int i; +uint offset =0 ; + +for (i =0 ; i < bip->bli_format_count; i++) { + vecp =xfs_buf_item_format_segment (bip, vecp, offset, + bip->bli_formatp[i]); + offset += bp->b_vec[i].bv_len; + } + } + +/* clear the in-memory inode buffer state now formatting is done. */ + bip->bli_flags &= ~XFS_BLI_INODE_BUF ;/* * Check to make sure everything is consistent.
@@ -697,24 +767,54 @@ xfs_buf_item_init(if (lip !=NULL && lip->li_type ==XFS_LI_BUF )return ; -/* -* chunks is the number of XFS_BLF_CHUNK size pieces -* the buffer can be divided into. Make sure not to -* truncate any pieces. map_size is the size of the -* bitmap needed to describe the chunks of the buffer. -*/ - chunks = (int )((XFS_BUF_COUNT (bp) + (XFS_BLF_CHUNK -1 )) >>XFS_BLF_SHIFT ); - map_size = (int )((chunks +NBWORD ) >>BIT_TO_WORD_SHIFT ); bip = (xfs_buf_log_item_t *)kmem_zone_zalloc (xfs_buf_item_zone,KM_SLEEP );xfs_log_item_init (mp, &bip->bli_item,XFS_LI_BUF , &xfs_buf_item_ops); bip->bli_buf = bp;xfs_buf_hold (bp); - bip->bli_format.blf_type =XFS_LI_BUF ; - bip->bli_format.blf_blkno = (__int64_t )XFS_BUF_ADDR (bp); - bip->bli_format.blf_len = (ushort )BTOBB (XFS_BUF_COUNT (bp)); - bip->bli_format.blf_map_size = map_size; + +/* +* chunks is the number of XFS_BLF_CHUNK size pieces the buffer +* can be divided into. Make sure not to truncate any pieces. +* map_size is the size of the bitmap needed to describe the +* chunks of the buffer. +*/ + bip->bli_format_count = bp->b_vec_count; +if (bip->bli_format_count ==1 ) { + chunks = (int )((XFS_BUF_COUNT (bp) + (XFS_BLF_CHUNK -1 )) >>XFS_BLF_SHIFT ); + map_size = (int )((chunks +NBWORD ) >>BIT_TO_WORD_SHIFT ); + + bip->bli_format.blf_type =XFS_LI_BUF ; + bip->bli_format.blf_blkno = (__int64_t )XFS_BUF_ADDR (bp); + bip->bli_format.blf_len = (ushort )BTOBB (XFS_BUF_COUNT (bp)); + bip->bli_format.blf_map_size = map_size; + }else { +/* +* Allocate an array to point to all the allocated format buffer +* structures. Then allocate the format buffer structures and +* initialise them. +*/ +int i; + + bip->bli_formatp =kmem_zalloc (bip->bli_format_count * +sizeof (struct xfs_buf_log_format *), +KM_SLEEP ); +for (i =0 ; i < bp->b_vec_count; i++) { +struct xfs_buf_log_format *blfp; + + chunks = (int )((bp->b_vec[i].bv_len + (XFS_BLF_CHUNK -1 )) >>XFS_BLF_SHIFT ); + map_size = (int )((chunks +NBWORD ) >>BIT_TO_WORD_SHIFT ); + + blfp =kmem_zalloc (sizeof (*blfp) + map_size,KM_SLEEP ); + bip->bli_formatp[i] = blfp; + + blfp->blf_type =XFS_LI_BUF ; + blfp->blf_blkno = (__int64_t )bp->b_vec[i].bv_bn; + blfp->blf_len = (ushort )BTOBB (bp->b_vec[i].bv_len); + blfp->blf_map_size = map_size; + } + }#ifdef XFS_TRANS_DEBUG /*
@@ -739,16 +839,12 @@ xfs_buf_item_init( bp->b_fspriv = bip; } - -/* -* Mark bytes first through last inclusive as dirty in the buf -* item's bitmap. -*/ void -xfs_buf_item_log ( -xfs_buf_log_item_t *bip, +xfs_buf_item_log_segment ( +struct xfs_buf_log_item *bip,uint first, -uint last) +uint last, +uint *map) {uint first_bit;uint last_bit;
@@ -761,12 +857,6 @@ xfs_buf_item_log(uint mask;/* -* Mark the item as having some dirty data for -* quick reference in xfs_buf_item_dirty. -*/ - bip->bli_flags |=XFS_BLI_DIRTY ; - -/* * Convert byte offsets to bit numbers. */ first_bit = first >>XFS_BLF_SHIFT ;
@@ -782,7 +872,7 @@ xfs_buf_item_log(* to set a bit in. */ word_num = first_bit >>BIT_TO_WORD_SHIFT ; - wordp = &(bip->bli_format.blf_data_map[word_num]); + wordp = &map[word_num];/* * Calculate the starting bit in the first word.
@@ -831,6 +921,55 @@ xfs_buf_item_log(/* +* Mark bytes first through last inclusive as dirty in the buf +* item's bitmap. +*/ +void +xfs_buf_item_log ( +xfs_buf_log_item_t *bip, +uint first, +uint last) +{ +int i; +uint start; +uint end; +struct xfs_buf *bp = bip->bli_buf; + +/* +* Mark the item as having some dirty data for +* quick reference in xfs_buf_item_dirty. +*/ + bip->bli_flags |=XFS_BLI_DIRTY ; + +if (bip->bli_format_count ==1 ) { +xfs_buf_item_log_segment (bip, first, last, + &bip->bli_format.blf_data_map[0 ]); +return ; + } + +/* +* walk each buffer segment and mark them dirty appropriately. +*/ + start =0 ; +for (i =0 ; i < bip->bli_format_count; i++) { +if (start > last) +break ; + end = start + bp->b_vec[i].bv_len; +if (first > end) { + start += bp->b_vec[i].bv_len; +continue ; + } +if (end > last) + end = last; + +xfs_buf_item_log_segment (bip, start, end, + &bip->bli_formatp[i]->blf_data_map[0 ]); + + start += bp->b_vec[i].bv_len; + } +} + +/* * Return 1 if the buffer has some data that has been logged (at any * point, not just the current transaction) and 0 if not. */
@@ -850,6 +989,15 @@ xfs_buf_item_free(kmem_free (bip->bli_logged);#endif /* XFS_TRANS_DEBUG */ +if (bip->bli_format_count >1 ) { +int i; +for (i =0 ; i < bip->bli_format_count; i++) { +kmem_free (bip->bli_formatp[i]); + } + } + +kmem_free (bip->bli_formatp); +kmem_zone_free (xfs_buf_item_zone, bip); }
fs/xfs/xfs_buf_item.h +5 -1
@@ -102,7 +102,11 @@ typedef struct xfs_buf_log_item {char *bli_orig;/* original buffer copy */ char *bli_logged;/* bytes logged (bitmap) */ #endif -xfs_buf_log_format_t bli_format;/* in-log header */ +xfs_buf_log_format_t **bli_formatp;/* array of in-log header ptrs */ +int bli_format_count;/* count of headers */ + +/* variable size so must be last */ +xfs_buf_log_format_t bli_format;/* embedded in-log header */ } xfs_buf_log_item_t;void xfs_buf_item_init (struct xfs_buf *,struct xfs_mount *);
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/12 xfs: add irec interfaces to xfs_trans_buf_get/read
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Add an irec interface to the transaction buffer API so that we can connect up the xfs_dabuf code to the new compound buffer API. Only support a single map at this point to simplify the implementation.
Also, just duplicate the existing code to minimise the impact of the change. This will be refactored later to remove all the duplicated code.
--- fs/xfs/xfs_trans.h | 7 ++ fs/xfs/xfs_trans_buf.c | 250 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 257 insertions(+), 0 deletions(-)
fs/xfs/xfs_trans.h +7 -0
@@ -458,6 +458,13 @@ struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddrint xfs_trans_read_buf (struct xfs_mount *,xfs_trans_t *,struct xfs_buftarg *,xfs_daddr_t ,int ,uint ,struct xfs_buf **); +struct xfs_buf *xfs_trans_get_buf_irec (struct xfs_trans *,struct xfs_buftarg *, +struct xfs_bmbt_irec *,int ,uint ); +int xfs_trans_read_buf_irec (struct xfs_mount *,struct xfs_trans *, +struct xfs_buftarg *, +struct xfs_bmbt_irec *,int ,uint , +struct xfs_buf **); +struct xfs_buf *xfs_trans_getsb (xfs_trans_t *,struct xfs_mount *,int );void xfs_trans_brelse (xfs_trans_t *,struct xfs_buf *);
fs/xfs/xfs_trans_buf.c +250 -0
262 lines not on this page · raw message
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 12/12 xfs: remove duplication in transaction buffer operations
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Remove the duplicated code introduced earlier in the series and make sure that multiple irec buffer operations work correctly.
--- fs/xfs/xfs_trans_buf.c | 351 ++++++++++------------------------------------- 1 files changed, 75 insertions(+), 276 deletions(-)
fs/xfs/xfs_trans_buf.c +75 -276
@@ -44,13 +44,27 @@ STATIC struct xfs_buf *xfs_trans_buf_item_match ( struct xfs_trans *tp, struct xfs_buftarg *target, - xfs_daddr_t blkno, - int len) + struct xfs_bmbt_irec *map, + int nmaps) { struct xfs_log_item_desc *lidp;struct xfs_buf_log_item *blip; +xfs_daddr_t blkno; +int len =0 ; +int i; + +if (map[0 ].br_state ==XFS_EXT_DADDR ) + blkno = map[0 ].br_startblock; +else + blkno =XFS_FSB_TO_DADDR (tp->t_mountp, map[0 ].br_startblock); + +for (i =0 ; i < nmaps; i++) { +if (map[0 ].br_state ==XFS_EXT_DADDR ) + len +=BBTOB (map[i].br_blockcount); +else + len +=XFS_FSB_TO_B (tp->t_mountp, map[0 ].br_blockcount); + } - len =BBTOB (len);list_for_each_entry (lidp, &tp->t_items, lid_trans) { blip = (struct xfs_buf_log_item *)lidp->lid_item; if (blip->bli_item.li_type == XFS_LI_BUF &&
@@ -122,90 +136,10 @@ xfs_trans_bjoin(trace_xfs_trans_bjoin (bp->b_fspriv); } -/* -* Get and lock the buffer for the caller if it is not already -* locked within the given transaction. If it is already locked -* within the transaction, just increment its lock recursion count -* and return a pointer to it. -* -* If the transaction pointer is NULL, make this just a normal -* get_buf() call. -*/ -xfs_buf_t * -xfs_trans_get_buf (xfs_trans_t *tp, -xfs_buftarg_t *target_dev, -xfs_daddr_t blkno, -int len, -uint flags) -{ -xfs_buf_t *bp; -xfs_buf_log_item_t *bip; - -if (flags ==0 ) - flags =XBF_LOCK |XBF_MAPPED ; - -/* -* 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 ); - -/* -* If we find the buffer in the cache with this transaction -* pointer in its b_fsprivate2 field, then we know we already -* have it locked. In this case we just increment the lock -* recursion count and return the buffer to the caller. -*/ - bp =xfs_trans_buf_item_match (tp, target_dev, blkno, len); -if (bp !=NULL ) { -ASSERT (xfs_buf_islocked (bp)); -if (XFS_FORCED_SHUTDOWN (tp->t_mountp)) { -xfs_buf_stale (bp); -XFS_BUF_DONE (bp); - } - -/* -* If the buffer is stale then it was binval'ed -* since last read. This doesn't matter since the -* caller isn't allowed to use the data anyway. -*/ -else if (XFS_BUF_ISSTALE (bp)) -ASSERT (!XFS_BUF_ISDELAYWRITE (bp)); - -ASSERT (bp->b_transp == tp); - bip = bp->b_fspriv; -ASSERT (bip !=NULL ); -ASSERT (atomic_read (&bip->bli_refcount) >0 ); - bip->bli_recur++; -trace_xfs_trans_get_buf_recur (bip); -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 ); -if (bp ==NULL ) { -return NULL ; - } - -ASSERT (!bp->b_error); - -_xfs_trans_bjoin (tp, bp,1 ); -trace_xfs_trans_get_buf (bp->b_fspriv); -return (bp); -} -struct xfs_buf *xfs_trans_get_buf_irec (struct xfs_trans *tp, -struct xfs_buftarg *target_dev, +struct xfs_buftarg *target,struct xfs_bmbt_irec *map,int nmaps,uint flags)
@@ -213,8 +147,6 @@ xfs_trans_get_buf_irec(struct xfs_buf *bp;struct xfs_buf_log_item *bip; -ASSERT_ALWAYS (nmaps ==1 ); -if (flags ==0 ) flags =XBF_LOCK |XBF_MAPPED ;
@@ -222,7 +154,7 @@ xfs_trans_get_buf_irec(* Default to a normal get_buf() call if the tp is NULL. */ if (tp ==NULL ) -return xfs_buf_get_irec (target_dev, map, nmaps, +return xfs_buf_get_irec (target, map, nmaps, flags |XBF_DONT_BLOCK );/*
@@ -231,9 +163,7 @@ xfs_trans_get_buf_irec(* have it locked. In this case we just increment the lock * recursion count and return the buffer to the caller. */ - bp =xfs_trans_buf_item_match (tp, target_dev, -XFS_FSB_TO_DADDR (tp->t_mountp, map[0 ].br_startblock), -XFS_FSB_TO_BB (tp->t_mountp, map[0 ].br_blockcount)); + bp =xfs_trans_buf_item_match (tp, target, map, nmaps);if (bp !=NULL ) {ASSERT (xfs_buf_islocked (bp));if (XFS_FORCED_SHUTDOWN (tp->t_mountp)) {
@@ -266,7 +196,7 @@ xfs_trans_get_buf_irec(* easily deadlock with our current transaction as well as cause * us to run out of stack space. */ - bp =xfs_buf_get_irec (target_dev, map, nmaps, flags |XBF_DONT_BLOCK ); + bp =xfs_buf_get_irec (target, map, nmaps, flags |XBF_DONT_BLOCK );if (bp ==NULL ) {return NULL ; }
@@ -279,6 +209,31 @@ xfs_trans_get_buf_irec( }/* +* Get and lock the buffer for the caller if it is not already +* locked within the given transaction. If it is already locked +* within the transaction, just increment its lock recursion count +* and return a pointer to it. +* +* If the transaction pointer is NULL, make this just a normal +* get_buf() call. +*/ +xfs_buf_t * +xfs_trans_get_buf ( +struct xfs_trans *tp, +struct xfs_buftarg *target, +xfs_daddr_t blkno, +int numblks, +uint flags) +{ +struct xfs_bmbt_irec map = { + .br_startblock = blkno, + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; +return xfs_trans_get_buf_irec (tp, target, &map,1 , flags); +} + +/* * Get and lock the superblock buffer of this file system for the * given transaction. *
@@ -334,186 +289,6 @@ int xfs_req_num;int xfs_error_mod =33 ;#endif -/* -* Get and lock the buffer for the caller if it is not already -* locked within the given transaction. If it has not yet been -* read in, read it from disk. If it is already locked -* within the transaction and already read in, just increment its -* lock recursion count and return a pointer to it. -* -* If the transaction pointer is NULL, make this just a normal -* read_buf() call. -*/ -int -xfs_trans_read_buf ( -xfs_mount_t *mp, -xfs_trans_t *tp, -xfs_buftarg_t *target, -xfs_daddr_t blkno, -int len, -uint flags, -xfs_buf_t **bpp) -{ -xfs_buf_t *bp; -xfs_buf_log_item_t *bip; -int error; - -if (flags ==0 ) - flags =XBF_LOCK |XBF_MAPPED ; - -/* -* 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 ); -if (!bp) -return (flags &XBF_TRYLOCK ) ? -EAGAIN :XFS_ERROR (ENOMEM ); - -if (bp->b_error) { - error = bp->b_error; -xfs_buf_ioerror_alert (bp, __func__); -xfs_buf_relse (bp); -return error; - } -#ifdef DEBUG -if (xfs_do_error) { -if (xfs_error_target == target) { -if (((xfs_req_num++) % xfs_error_mod) ==0 ) { -xfs_buf_relse (bp); -xfs_debug (mp,"Returning error!" ); -return XFS_ERROR (EIO ); - } - } - } -#endif -if (XFS_FORCED_SHUTDOWN (mp)) - goto shutdown_abort; - *bpp = bp; -return 0 ; - } - -/* -* If we find the buffer in the cache with this transaction -* pointer in its b_fsprivate2 field, then we know we already -* have it locked. If it is already read in we just increment -* the lock recursion count and return the buffer to the caller. -* If the buffer is not yet read in, then we read it in, increment -* the lock recursion count, and return it to the caller. -*/ - bp =xfs_trans_buf_item_match (tp, target, blkno, len); -if (bp !=NULL ) { -ASSERT (xfs_buf_islocked (bp)); -ASSERT (bp->b_transp == tp); -ASSERT (bp->b_fspriv !=NULL ); -ASSERT (!bp->b_error); -if (!(XFS_BUF_ISDONE (bp))) { -trace_xfs_trans_read_buf_io (bp, _RET_IP_); -ASSERT (!XFS_BUF_ISASYNC (bp)); -XFS_BUF_READ (bp); -xfsbdstrat (tp->t_mountp, bp); - error =xfs_buf_iowait (bp); -if (error) { -xfs_buf_ioerror_alert (bp, __func__); -xfs_buf_relse (bp); -/* -* We can gracefully recover from most read -* errors. Ones we can't are those that happen -* after the transaction's already dirty. -*/ -if (tp->t_flags &XFS_TRANS_DIRTY ) -xfs_force_shutdown (tp->t_mountp, -SHUTDOWN_META_IO_ERROR ); -return error; - } - } -/* -* We never locked this buf ourselves, so we shouldn't -* brelse it either. Just get out. -*/ -if (XFS_FORCED_SHUTDOWN (mp)) { -trace_xfs_trans_read_buf_shut (bp, _RET_IP_); - *bpp =NULL ; -return XFS_ERROR (EIO ); - } - - - bip = bp->b_fspriv; - bip->bli_recur++; - -ASSERT (atomic_read (&bip->bli_refcount) >0 ); -trace_xfs_trans_read_buf_recur (bip); - *bpp = bp; -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 ); -if (bp ==NULL ) { - *bpp =NULL ; -return (flags &XBF_TRYLOCK ) ? -0 :XFS_ERROR (ENOMEM ); - } -if (bp->b_error) { - error = bp->b_error; -xfs_buf_stale (bp); -XFS_BUF_DONE (bp); -xfs_buf_ioerror_alert (bp, __func__); -if (tp->t_flags &XFS_TRANS_DIRTY ) -xfs_force_shutdown (tp->t_mountp,SHUTDOWN_META_IO_ERROR ); -xfs_buf_relse (bp); -return error; - } -#ifdef DEBUG -if (xfs_do_error && !(tp->t_flags &XFS_TRANS_DIRTY )) { -if (xfs_error_target == target) { -if (((xfs_req_num++) % xfs_error_mod) ==0 ) { -xfs_force_shutdown (tp->t_mountp, -SHUTDOWN_META_IO_ERROR ); -xfs_buf_relse (bp); -xfs_debug (mp,"Returning trans error!" ); -return XFS_ERROR (EIO ); - } - } - } -#endif -if (XFS_FORCED_SHUTDOWN (mp)) - goto shutdown_abort; - -_xfs_trans_bjoin (tp, bp,1 ); -trace_xfs_trans_read_buf (bp->b_fspriv); - - *bpp = bp; -return 0 ; - -shutdown_abort: -/* -* the theory here is that buffer is good but we're -* bailing out because the filesystem is being forcibly -* shut down. So we should leave the b_flags alone since -* the buffer's not staled and just get out. - */ -#if defined(DEBUG ) -if (XFS_BUF_ISSTALE (bp) &&XFS_BUF_ISDELAYWRITE (bp)) -xfs_notice (mp,"about to pop assert, bp == 0x%p" , bp); -#endif -ASSERT ((bp->b_flags & (XBF_STALE |XBF_DELWRI )) != - (XBF_STALE |XBF_DELWRI )); - -trace_xfs_trans_read_buf_shut (bp, _RET_IP_); -xfs_buf_relse (bp); - *bpp =NULL ; -return XFS_ERROR (EIO ); -} - - int xfs_trans_read_buf_irec( struct xfs_mount *mp,
@@ -528,8 +303,6 @@ xfs_trans_read_buf_irec(xfs_buf_log_item_t *bip;int error; -ASSERT_ALWAYS (nmaps ==1 ); -if (flags ==0 ) flags =XBF_LOCK |XBF_MAPPED ;
@@ -574,9 +347,7 @@ xfs_trans_read_buf_irec(* If the buffer is not yet read in, then we read it in, increment * the lock recursion count, and return it to the caller. */ - bp =xfs_trans_buf_item_match (tp, target, -XFS_FSB_TO_DADDR (mp, map[0 ].br_startblock), -XFS_FSB_TO_BB (mp, map[0 ].br_blockcount)); + bp =xfs_trans_buf_item_match (tp, target, map, nmaps);if (bp !=NULL ) {ASSERT (xfs_buf_islocked (bp));ASSERT (bp->b_transp == tp);
@@ -689,6 +460,34 @@ shutdown_abort: }/* +* Get and lock the buffer for the caller if it is not already +* locked within the given transaction. If it has not yet been +* read in, read it from disk. If it is already locked +* within the transaction and already read in, just increment its +* lock recursion count and return a pointer to it. +* +* If the transaction pointer is NULL, make this just a normal +* read_buf() call. +*/ +int +xfs_trans_read_buf ( +xfs_mount_t *mp, +xfs_trans_t *tp, +xfs_buftarg_t *target, +xfs_daddr_t blkno, +int numblks, +uint flags, +xfs_buf_t **bpp) +{ +struct xfs_bmbt_irec map = { + .br_startblock = blkno, + .br_blockcount = numblks, + .br_state =XFS_EXT_DADDR , + }; +return xfs_trans_read_buf_irec (mp, tp, target, &map,1 , flags, bpp); +} + +/* * Release the buffer bp which was previously acquired with one of the * xfs_trans_... buffer allocation routines if the buffer has not * been modified within this transaction. If the buffer is modified
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 11/12 xfs: remove struct xfs_dabuf and infrastructure
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The struct xfs_dabuf now only tracks a single xfs_buf and all the information it holds can be gained directly from the xfs_buf. Hence we can remove the struct dabuf and pass the xfs_buf around everywhere.
Kill the struct dabuf and the associated infrastructure.
--- fs/xfs/xfs_attr.c | 78 +++++------ fs/xfs/xfs_attr_leaf.c | 255 +++++++++++++++++++---------------- fs/xfs/xfs_attr_leaf.h | 21 ++-- fs/xfs/xfs_da_btree.c | 338 ++++++++++++++++------------------------------ fs/xfs/xfs_da_btree.h | 32 +---- fs/xfs/xfs_dir2.c | 4 +- fs/xfs/xfs_dir2_block.c | 118 +++++++---------- fs/xfs/xfs_dir2_data.c | 50 ++++---- fs/xfs/xfs_dir2_leaf.c | 191 +++++++++++++-------------- fs/xfs/xfs_dir2_node.c | 236 ++++++++++++++------------------- fs/xfs/xfs_dir2_priv.h | 46 ++++---- fs/xfs/xfs_dir2_sf.c | 4 +- fs/xfs/xfs_super.c | 9 +- 13 files changed, 602 insertions(+), 780 deletions(-)
fs/xfs/xfs_attr.c +36 -42
@@ -897,7 +897,7 @@ STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args) {xfs_inode_t *dp; -xfs_dabuf_t *bp; +struct xfs_buf *bp;int retval, error, committed, forkoff;/*
@@ -917,11 +917,11 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)*/ retval =xfs_attr_leaf_lookup_int (bp, args);if ((args->flags &ATTR_REPLACE ) && (retval ==ENOATTR )) { -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp);return (retval); }else if (retval ==EEXIST ) {if (args->flags &ATTR_CREATE ) {/* pure create op */ -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp);return (retval); } args->op_flags |=XFS_DA_OP_RENAME ;/* an atomic rename */
@@ -936,7 +936,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)* if required. */ retval =xfs_attr_leaf_add (bp, args); -xfs_da_buf_done (bp);if (retval ==ENOSPC ) {/* * Promote the attribute list to the Btree format, then
@@ -1064,8 +1063,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)*/ if (committed)xfs_trans_ijoin (args->trans, dp,0 ); - }else -xfs_da_buf_done (bp); + }/* * Commit the remove and start the next trans in series.
@@ -1091,7 +1089,7 @@ STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args) {xfs_inode_t *dp; -xfs_dabuf_t *bp; +struct xfs_buf *bp;int error, committed, forkoff;/*
@@ -1108,7 +1106,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)ASSERT (bp !=NULL ); error =xfs_attr_leaf_lookup_int (bp, args);if (error ==ENOATTR ) { -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp);return (error); }
@@ -1138,8 +1136,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)*/ if (committed)xfs_trans_ijoin (args->trans, dp,0 ); - }else -xfs_da_buf_done (bp); + }return (0 ); }
@@ -1152,7 +1149,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) STATIC intxfs_attr_leaf_get (xfs_da_args_t *args) { -xfs_dabuf_t *bp; +struct xfs_buf *bp;int error; args->blkno =0 ;
@@ -1164,11 +1161,11 @@ xfs_attr_leaf_get(xfs_da_args_t *args) error =xfs_attr_leaf_lookup_int (bp, args);if (error !=EEXIST ) { -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp);return (error); } error =xfs_attr_leaf_getvalue (bp, args); -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp);if (!error && (args->rmtblkno >0 ) && !(args->flags &ATTR_KERNOVAL )) { error =xfs_attr_rmtval_get (args); }
@@ -1183,23 +1180,23 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) {xfs_attr_leafblock_t *leaf;int error; -xfs_dabuf_t *bp; +struct xfs_buf *bp; context->cursor->blkno =0 ; error =xfs_da_read_buf (NULL , context->dp,0 ,-1 , &bp,XFS_ATTR_FORK );if (error)return XFS_ERROR (error);ASSERT (bp !=NULL ); - leaf = bp->data; + leaf = bp->b_addr;if (unlikely (leaf->hdr.info.magic !=cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ))) {XFS_CORRUPTION_ERROR ("xfs_attr_leaf_list" ,XFS_ERRLEVEL_LOW , context->dp->i_mount, leaf); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return XFS_ERROR (EFSCORRUPTED ); } error =xfs_attr_leaf_list_int (bp, context); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return XFS_ERROR (error); }
@@ -1481,7 +1478,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)xfs_da_state_t *state;xfs_da_state_blk_t *blk;xfs_inode_t *dp; -xfs_dabuf_t *bp; +struct xfs_buf *bp;int retval, error, committed, forkoff;/*
@@ -1591,14 +1588,13 @@ xfs_attr_node_removename(xfs_da_args_t *args)*/ ASSERT (state->path.active ==1 );ASSERT (state->path.blk[0 ].bp); -xfs_da_buf_done (state->path.blk[0 ].bp); state->path.blk[0 ].bp =NULL ; error =xfs_da_read_buf (args->trans, args->dp,0 ,-1 , &bp,XFS_ATTR_FORK );if (error) goto out; -ASSERT ((((xfs_attr_leafblock_t *)bp->data)->hdr.info.magic) == +ASSERT ((((xfs_attr_leafblock_t *)bp->b_addr)->hdr.info.magic) ==cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ));if ((forkoff =xfs_attr_shortform_allfit (bp, dp))) {
@@ -1625,7 +1621,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)if (committed)xfs_trans_ijoin (args->trans, dp,0 ); }else -xfs_da_brelse (args->trans, bp); +xfs_trans_brelse (args->trans, bp); } error =0 ;
@@ -1655,8 +1651,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->bp) { - blk->disk_blkno =xfs_da_blkno (blk->bp); -xfs_da_buf_done (blk->bp); + blk->disk_blkno =XFS_BUF_ADDR (blk->bp); blk->bp =NULL ; }else { blk->disk_blkno =0 ;
@@ -1671,8 +1666,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)ASSERT ((path->active >=0 ) && (path->active <XFS_DA_NODE_MAXDEPTH ));for (blk = path->blk, level =0 ; level < path->active; blk++, level++) {if (blk->bp) { - blk->disk_blkno =xfs_da_blkno (blk->bp); -xfs_da_buf_done (blk->bp); + blk->disk_blkno =XFS_BUF_ADDR (blk->bp); blk->bp =NULL ; }else { blk->disk_blkno =0 ;
@@ -1782,7 +1776,7 @@ xfs_attr_node_get(xfs_da_args_t *args)* If not in a transaction, we have to release all the buffers. */ for (i =0 ; i < state->path.active; i++) { -xfs_da_brelse (args->trans, state->path.blk[i].bp); +xfs_trans_brelse (args->trans, state->path.blk[i].bp); state->path.blk[i].bp =NULL ; }
@@ -1798,7 +1792,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)xfs_da_intnode_t *node;xfs_da_node_entry_t *btree;int error, i; -xfs_dabuf_t *bp; +struct xfs_buf *bp; cursor = context->cursor; cursor->initted =1 ;
@@ -1815,30 +1809,30 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)if ((error !=0 ) && (error !=EFSCORRUPTED ))return (error);if (bp) { - node = bp->data; + node = bp->b_addr;switch (be16_to_cpu (node->hdr.info.magic)) {case XFS_DA_NODE_MAGIC :trace_xfs_attr_list_wrong_blk (context); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); bp =NULL ;break ;case XFS_ATTR_LEAF_MAGIC : - leaf = bp->data; + leaf = bp->b_addr;if (cursor->hashval >be32_to_cpu (leaf->entries[be16_to_cpu (leaf->hdr.count)-1 ].hashval)) {trace_xfs_attr_list_wrong_blk (context); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); bp =NULL ; }else if (cursor->hashval <=be32_to_cpu (leaf->entries[0 ].hashval)) {trace_xfs_attr_list_wrong_blk (context); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); bp =NULL ; }break ;default :trace_xfs_attr_list_wrong_blk (context); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); bp =NULL ; } }
@@ -1863,7 +1857,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) context->dp->i_mount);return (XFS_ERROR (EFSCORRUPTED )); } - node = bp->data; + node = bp->b_addr;if (node->hdr.info.magic ==cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ))break ;
@@ -1873,7 +1867,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)XFS_ERRLEVEL_LOW , context->dp->i_mount, node); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return (XFS_ERROR (EFSCORRUPTED )); } btree = node->btree;
@@ -1888,10 +1882,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) } }if (i ==be16_to_cpu (node->hdr.count)) { -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return (0 ); } -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); } }ASSERT (bp !=NULL );
@@ -1902,24 +1896,24 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)* adding the information. */ for (;;) { - leaf = bp->data; + leaf = bp->b_addr;if (unlikely (leaf->hdr.info.magic !=cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ))) {XFS_CORRUPTION_ERROR ("xfs_attr_node_list(4)" ,XFS_ERRLEVEL_LOW , context->dp->i_mount, leaf); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return (XFS_ERROR (EFSCORRUPTED )); } error =xfs_attr_leaf_list_int (bp, context);if (error) { -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return error; }if (context->seen_enough || leaf->hdr.info.forw ==0 )break ; cursor->blkno =be32_to_cpu (leaf->hdr.info.forw); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp); error =xfs_da_read_buf (NULL , context->dp, cursor->blkno,-1 , &bp,XFS_ATTR_FORK );if (error)
@@ -1931,7 +1925,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)return (XFS_ERROR (EFSCORRUPTED )); } } -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);return (0 ); }
fs/xfs/xfs_attr_leaf.c +138 -117
773 lines not on this page · raw message
fs/xfs/xfs_attr_leaf.h +10 -11
@@ -31,7 +31,6 @@struct attrlist ;struct attrlist_cursor_kern ;struct xfs_attr_list_context ; -struct xfs_dabuf ;struct xfs_da_args ;struct xfs_da_state ;struct xfs_da_state_blk ;
@@ -215,7 +214,7 @@ int xfs_attr_shortform_getvalue(struct xfs_da_args *args);int xfs_attr_shortform_to_leaf (struct xfs_da_args *args);int xfs_attr_shortform_remove (struct xfs_da_args *args);int xfs_attr_shortform_list (struct xfs_attr_list_context *context); -int xfs_attr_shortform_allfit (struct xfs_dabuf *bp,struct xfs_inode *dp); +int xfs_attr_shortform_allfit (struct xfs_buf *bp,struct xfs_inode *dp);int xfs_attr_shortform_bytesfit (xfs_inode_t *dp,int bytes);
@@ -223,7 +222,7 @@ int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);* Internal routines when attribute fork size == XFS_LBSIZE(mp). */ int xfs_attr_leaf_to_node (struct xfs_da_args *args); -int xfs_attr_leaf_to_shortform (struct xfs_dabuf *bp, +int xfs_attr_leaf_to_shortform (struct xfs_buf *bp,struct xfs_da_args *args,int forkoff);int xfs_attr_leaf_clearflag (struct xfs_da_args *args);int xfs_attr_leaf_setflag (struct xfs_da_args *args);
@@ -235,14 +234,14 @@ int xfs_attr_leaf_flipflags(xfs_da_args_t *args);int xfs_attr_leaf_split (struct xfs_da_state *state,struct xfs_da_state_blk *oldblk,struct xfs_da_state_blk *newblk); -int xfs_attr_leaf_lookup_int (struct xfs_dabuf *leaf, +int xfs_attr_leaf_lookup_int (struct xfs_buf *leaf,struct xfs_da_args *args); -int xfs_attr_leaf_getvalue (struct xfs_dabuf *bp,struct xfs_da_args *args); -int xfs_attr_leaf_add (struct xfs_dabuf *leaf_buffer, +int xfs_attr_leaf_getvalue (struct xfs_buf *bp,struct xfs_da_args *args); +int xfs_attr_leaf_add (struct xfs_buf *leaf_buffer,struct xfs_da_args *args); -int xfs_attr_leaf_remove (struct xfs_dabuf *leaf_buffer, +int xfs_attr_leaf_remove (struct xfs_buf *leaf_buffer,struct xfs_da_args *args); -int xfs_attr_leaf_list_int (struct xfs_dabuf *bp, +int xfs_attr_leaf_list_int (struct xfs_buf *bp,struct xfs_attr_list_context *context);/*
@@ -257,9 +256,9 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);/* * Utility routines. */ -xfs_dahash_t xfs_attr_leaf_lasthash (struct xfs_dabuf *bp,int *count); -int xfs_attr_leaf_order (struct xfs_dabuf *leaf1_bp, -struct xfs_dabuf *leaf2_bp); +xfs_dahash_t xfs_attr_leaf_lasthash (struct xfs_buf *bp,int *count); +int xfs_attr_leaf_order (struct xfs_buf *leaf1_bp, +struct xfs_buf *leaf2_bp);int xfs_attr_leaf_newentsize (int namelen,int valuelen,int blocksize,int *local);#endif /* __XFS_ATTR_LEAF_H__ */
fs/xfs/xfs_da_btree.c +118 -220
857 lines not on this page · raw message
fs/xfs/xfs_da_btree.h +5 -27
@@ -133,20 +133,6 @@ typedef struct xfs_da_args { { XFS_DA_OP_CILOOKUP, "CILOOKUP" }/* -* Structure to describe buffer(s) for a block. -* This is needed in the directory version 2 format case, when -* multiple non-contiguous fsblocks might be needed to cover one -* logical directory block. -* If the buffer count is 1 then the data pointer points to the -* same place as the b_addr field for the buffer, else to kmem_alloced memory. -*/ -typedef struct xfs_dabuf { -short bbcount;/* how large is data in bbs */ -void *data;/* pointer for buffers' data */ -struct xfs_buf *bp;/* actually nbuf of these */ -}xfs_dabuf_t ; - -/* * Storage for holding state during Btree searches and split/join ops. * * Only need space for 5 intermediate nodes. With a minimum of 62-way
@@ -154,7 +140,7 @@ typedef struct xfs_dabuf {* which is slightly more than enough. */ typedef struct xfs_da_state_blk { - xfs_dabuf_t *bp; /* buffer containing block */ + struct xfs_buf *bp; /* buffer containing block */ xfs_dablk_t blkno; /* filesystem blkno of buffer */ xfs_daddr_t disk_blkno; /* on-disk blkno (in BBs) of buffer */ int index; /* relevant index into block */
@@ -207,7 +193,7 @@ struct xfs_nameops {* Routines used for growing the Btree. */ int xfs_da_node_create (xfs_da_args_t *args,xfs_dablk_t blkno,int level, -xfs_dabuf_t **bpp,int whichfork); +struct xfs_buf **bpp,int whichfork);int xfs_da_split (xfs_da_state_t *state);/*
@@ -237,14 +223,14 @@ int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno, int count);int xfs_da_get_buf (struct xfs_trans *trans,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mappedbno, -xfs_dabuf_t **bp,int whichfork); +struct xfs_buf **bp,int whichfork);int xfs_da_read_buf (struct xfs_trans *trans,struct xfs_inode *dp,xfs_dablk_t bno,xfs_daddr_t mappedbno, -xfs_dabuf_t **bpp,int whichfork); +struct xfs_buf **bpp,int whichfork);xfs_daddr_t xfs_da_reada_buf (struct xfs_trans *trans,struct xfs_inode *dp,xfs_dablk_t bno,int whichfork);int xfs_da_shrink_inode (xfs_da_args_t *args,xfs_dablk_t dead_blkno, -xfs_dabuf_t *dead_buf); +struct xfs_buf *dead_buf);uint xfs_da_hashname (const __uint8_t *name_string,int name_length); enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
@@ -254,15 +240,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,xfs_da_state_t *xfs_da_state_alloc (void );void xfs_da_state_free (xfs_da_state_t *state); -void xfs_da_buf_done (xfs_dabuf_t *dabuf); -void xfs_da_log_buf (struct xfs_trans *tp,xfs_dabuf_t *dabuf,uint first, -uint last); -void xfs_da_brelse (struct xfs_trans *tp,xfs_dabuf_t *dabuf); -void xfs_da_binval (struct xfs_trans *tp,xfs_dabuf_t *dabuf); -xfs_daddr_t xfs_da_blkno (xfs_dabuf_t *dabuf); -extern struct kmem_zone *xfs_da_state_zone; -extern struct kmem_zone *xfs_dabuf_zone;extern const struct xfs_nameops xfs_default_nameops;#endif /* __XFS_DA_BTREE_H__ */
fs/xfs/xfs_dir2.c +2 -2
@@ -593,7 +593,7 @@ intxfs_dir2_shrink_inode ( xfs_da_args_t *args, xfs_dir2_db_t db, - xfs_dabuf_t *bp) + struct xfs_buf *bp) {xfs_fileoff_t bno;/* directory file offset */ xfs_dablk_t da;/* directory file offset */
@@ -635,7 +635,7 @@ xfs_dir2_shrink_inode(/* * Invalidate the buffer from the transaction. */ -xfs_da_binval (tp, bp); +xfs_trans_binval (tp, bp);/* * If it's not a data block, we're done. */
fs/xfs/xfs_dir2_block.c +51 -67
351 lines not on this page · raw message
fs/xfs/xfs_dir2_data.c +25 -25
141 lines not on this page · raw message
fs/xfs/xfs_dir2_leaf.c +91 -100
465 lines not on this page · raw message
fs/xfs/xfs_dir2_node.c +100 -136
236 lines not on this page · raw message
fs/xfs/xfs_dir2_priv.h +23 -23
46 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.5.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · Dave Chinner
The series passes xfstests on 4k/4k, 4k/512b, 64k/4k and 64k/512b (dirblksz/fsblksz) configurations without any new regressions, and survives 100 million inode
fs_markbenchmarks on a 17TB filesystem using 4k/4k, 64k/512b and 64k/512b configurations.
Do you have any benchmark numbers showing performance improvements for the large directory block case?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Dave Chinner
The series passes xfstests on 4k/4k, 4k/512b, 64k/4k and 64k/512b (dirblksz/fsblksz) configurations without any new regressions, and survives 100 million inode
fs_markbenchmarks on a 17TB filesystem using 4k/4k, 64k/512b and 64k/512b configurations.Do you have any benchmark numbers showing performance improvements for the large directory block case?
I haven't run real comparisons yet (it hasn't been working for long enough for me to do so), but I suspect that the gains are lost in the amount of CPU overhead the buffer formatting code is consuming - it's around 40-50% of the entire CPU time on the parallel create tests:
+ 13.10% [kernel] [k] memcpy + 7.94% [kernel] [k] xfs_next_bit + 7.63% [kernel] [k] xfs_buf_find_irec.isra.11 + 5.86% [kernel] [k] xfs_buf_offset + 4.36% [kernel] [k] xfs_buf_item_format_segment + 4.11% [kernel] [k] xfs_buf_item_size_segment.isra.0
That's all cpu usage under the transaction commit path.
Basically I'm getting 100-110k files/s with 4k directory sizes, and 70-80k files/s with 64k dirs for the same workload consuming the same amount of roughly the same CPU time. Killing the buffer logging overhead (which barely registers on the 4k directory block size) looks like it will now bring parity to large block size directory performance compared to 4k block size performance because the amount written to the log (~30MB/s) is identical for both configurations...
It might cwbe as simple as checking the hamming weight of the dirty bitmap, and if it is over a certain amount just log the buffer in it's entirity, skipping the bitmap based dirty region processing altogether...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 01/12] xfs: remove remaining scraps of struct xfs_iomap
In reply to Dave ChinnerQuoted 1 line · Dave Chinner
From: Dave Chinner <[email protected]>
Oh the memories..
Looks fine,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 02/12] xfs: clean up buffer get/read call API
In reply to Dave Chinnerfs/xfs/xfs_buf.c xfs_buf_alloc( · line 204
Quoted 13 lines · Dave Chinner
fs/xfs/xfs_buf.c +4
-2- bp->b_file_offset = range_base; + bp->b_file_offset = blkno <<BBSHIFT ;/* * Set buffer_length and count_desired to the same value initially. * I/O routines should use count_desired, which will be the same in * most cases but may be reset (e.g. XFS recovery). */ - bp->b_buffer_length = bp->b_count_desired = range_length; + bp->b_buffer_length = bp->b_count_desired = numblks <<BBSHIFT ; bp->b_flags = flags; + +/* XXX: we have the block number. Why don't we just set it here? */ bp->b_bn =XFS_BUF_DADDR_NULL ;
If you touch all this anyway I think we should kill one of b_file_offset and b_bn. Given that b_file_offset is never used outside of xfs_buf.c and with your patch we're using the block number much more often than the byte offset b_file_offset seems like the likely candidate to kill to me.
Otherwise this looks good to me,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
I've been really busy the last days and only managed to look over this a bit while waiting for compiles and benchmarks.
The only really major comment I have is that I start to really dislike the way struct xfs_bmbt_irec is used in the compound buffers. The XFS_EXT_DADDR flag basically gives the data types in there a totally different meaning and is really confusing for anyone reading the code:
either we're using a "normal" one passes in from the directory code, or an artificial one used internally, which uses different units.
I suspect we'd really be much better off introducing a new, smaller type here, especially as it's only seen inside the buffer code:
struct xfs_buf_map {
sector_t bm_bno;
size_t bm_len;
};any use it consistently, that is also use it to replace
b_file_offset/b_buffer_length and b_bn. This will also make my number
two suggestion a lot cleaner, that is make sure the new abstraction can be implemented for reading/writing log buffers that wrap around, and allow to kill off xfs_buf_associate_memory entirely.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/12] xfs: introduce a compound buffer construct
In reply to Dave Chinnerfs/xfs/xfs_buf.h typedef void (*xfs_buf_iodone_t)(struct xfs_buf *); · line 129
Quoted 5 lines
fs/xfs/xfs_buf.h +5
-0+struct xfs_buf_vec { +xfs_daddr_t bv_bn;/* block number for I/O */ +size_t bv_len;/* size of I/O */ +}; +#define XB_VECS 2
Why do we embedd to of these by default? In general we'd either have one or a number much bigger than two here.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/12] xfs: add compound buffer get and read interfaces
In reply to Dave ChinnerAfter looking over all the patches I really thing we should be passing struct xfs_buf_vec arguments to the functions, and provide a helper to convert struct xfs_bmbt_irec to the callers. That avoids having to add the XFS_EXT_DADDR hack, and keeps the amount of data structures used in the buffer cache small.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 11/12] xfs: remove struct xfs_dabuf and infrastructure
In reply to Dave Chinnerfs/xfs/xfs_attr.c xfs_attr_leaf_list(xfs_attr_list_context_t *context) · line 1194
Quoted 8 lines
fs/xfs/xfs_attr.c +2
-2ASSERT (bp !=NULL ); - leaf = bp->data; + leaf = bp->b_addr;if (unlikely (leaf->hdr.info.magic !=cpu_to_be16 (XFS_ATTR_LEAF_MAGIC ))) {XFS_CORRUPTION_ERROR ("xfs_attr_leaf_list" ,XFS_ERRLEVEL_LOW , context->dp->i_mount, leaf); -xfs_da_brelse (NULL , bp); +xfs_trans_brelse (NULL , bp);
Wouldn't a direct call to xfs_buf_relse be the more logical replacement for a call to xfs_da_brelse with a constant NULL transaction argument?
fs/xfs/xfs_attr_leaf.c xfs_attr_shortform_list(xfs_attr_list_context_t *context) · line 726
Quoted 5 lines
int
fs/xfs/xfs_attr_leaf.c +3
-1-xfs_attr_shortform_allfit (xfs_dabuf_t *bp, xfs_inode_t *dp) +xfs_attr_shortform_allfit ( + struct xfs_buf *bp, + struct xfs_inode *dp)
If you'd use one more tab all arguments would be full aligned. This also happens in a few more places.
fs/xfs/xfs_attr_leaf.c xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) · line 765
Quoted 4 lines
fs/xfs/xfs_attr_leaf.c +3
-1-xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) +xfs_attr_leaf_to_shortform ( + struct xfs_buf *bp, + xfs_da_args_t *args,
Also if you touch the argument list anyway please replace xfs_da_args_t with struct xfs_da_args.
Quoted 6 lines
void
xfs_da_state_free(xfs_da_state_t *state)
{fs/xfs/xfs_da_btree.c +0
-2-int i; -xfs_da_state_kill_altpath (state);
fs/xfs/xfs_da_btree.c xfs_da_state_kill_altpath(xfs_da_state_t *state) · line 2201
Quoted 10 lines
fs/xfs/xfs_da_btree.c +0
-6-for (i =0 ; i < state->path.active; i++) { -if (state->path.blk[i].bp) -xfs_da_buf_done (state->path.blk[i].bp); - } -if (state->extravalid && state->extrablk.bp) -xfs_da_buf_done (state->extrablk.bp);#ifdef DEBUG memset ((char *)state,0 ,sizeof (*state));#endif /* DEBUG */ kmem_zone_free (xfs_da_state_zone, state);
We really should kill that memset, which only defeats slab poisoning. Not in this patch, though.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/12] xfs: remove duplication in transaction buffer operations
In reply to Dave Chinnerfs/xfs/xfs_trans_buf.c xfs_trans_get_buf_irec( · line 217
Quoted 6 lines
fs/xfs/xfs_trans_buf.c +0
-2@@ -213,8 +147,6 @@ xfs_trans_get_buf_irec(struct xfs_buf *bp;struct xfs_buf_log_item *bip; -ASSERT_ALWAYS (nmaps ==1 ); -
Shouldn't this have been removed as soon as actual multiple buffer support was introduced?
fs/xfs/xfs_trans_buf.c xfs_trans_read_buf_irec( · line 532
Quoted 6 lines
fs/xfs/xfs_trans_buf.c +0
-2@@ -528,8 +303,6 @@ xfs_trans_read_buf_irec(xfs_buf_log_item_t *bip;int error; -ASSERT_ALWAYS (nmaps ==1 ); -
Same here.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 18 lines · Christoph Hellwig
I've been really busy the last days and only managed to look over this a bit while waiting for compiles and benchmarks.
The only really major comment I have is that I start to really dislike the way struct
xfs_bmbt_irecis used in the compound buffers. TheXFS_EXT_DADDRflag basically gives the data types in there a totally different meaning and is really confusing for anyone reading the code:
either we're using a "normal" one passes in from the directory code, or an artificial one used internally, which uses different units.I suspect we'd really be much better off introducing a new, smaller type here, especially as it's only seen inside the buffer code:
struct xfs_buf_map { sector_t bm_bno; size_t bm_len; };
Quoted 5 lines
any use it consistently, that is also use it to replace
b_file_offset/b_buffer_length andb_bn. This will also make my number
two suggestion a lot cleaner, that is make sure the new abstraction can be implemented for reading/writing log buffers that wrap around, and allow to kill offxfs_buf_associate_memoryentirely.
Yeah, I was a bit unsure of the best way to do this. I started with the bmbt_irec code because it already existed and was easy to pass in from the directory code. It wasn't until I realised the sector addressing issue later on that the XFS_EXT_DADDR came about. That was a simple way of making it work, rather than rewriting the patches again...
Ok, I'll go back and rewrite them to use a xfs_buf_map/vec and try to address all your other points as well. Stay tuned.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs