From patchwork Fri Jul 12 21:34:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11042705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF61B1395 for ; Fri, 12 Jul 2019 21:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F1A128450 for ; Fri, 12 Jul 2019 21:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8207528475; Fri, 12 Jul 2019 21:34:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFFC028450 for ; Fri, 12 Jul 2019 21:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728063AbfGLVeW (ORCPT ); Fri, 12 Jul 2019 17:34:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54794 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbfGLVeW (ORCPT ); Fri, 12 Jul 2019 17:34:22 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8021804F2 for ; Fri, 12 Jul 2019 21:34:21 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79ADB60A9A for ; Fri, 12 Jul 2019 21:34:21 +0000 (UTC) Subject: [PATCH 1/4] xfsprogs: reorder functions in libxfs/trans.c To: linux-xfs References: From: Eric Sandeen Message-ID: <5cfffec2-092e-5409-e89f-48b5fd905ac2@redhat.com> Date: Fri, 12 Jul 2019 16:34:20 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 12 Jul 2019 21:34:21 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This puts these functions in libxfs/trans.c in the same order as they appear in kernelspace xfs_trans_buf.c for easier comparison. No functional changes. Signed-off-by: Eric Sandeen Reviewed-by: Carlos Maiolino diff --git a/libxfs/trans.c b/libxfs/trans.c index 5c56b4fe..8954f0fe 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -330,80 +330,6 @@ libxfs_trans_cancel( xfs_trans_free(tp); } -void -libxfs_trans_inode_alloc_buf( - xfs_trans_t *tp, - xfs_buf_t *bp) -{ - xfs_buf_log_item_t *bip = bp->b_log_item; - - ASSERT(bp->b_transp == tp); - ASSERT(bip != NULL); - bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF; - xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF); -} - -/* - * Mark a buffer dirty in the transaction. - */ -void -libxfs_trans_dirty_buf( - struct xfs_trans *tp, - struct xfs_buf *bp) -{ - struct xfs_buf_log_item *bip = bp->b_log_item; - - ASSERT(bp->b_transp == tp); - ASSERT(bip != NULL); - - tp->t_flags |= XFS_TRANS_DIRTY; - set_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); -} - -/* - * This is called to mark bytes first through last inclusive of the given - * buffer as needing to be logged when the transaction is committed. - * The buffer must already be associated with the given transaction. - * - * First and last are numbers relative to the beginning of this buffer, - * so the first byte in the buffer is numbered 0 regardless of the - * value of b_blkno. - */ -void -libxfs_trans_log_buf( - struct xfs_trans *tp, - struct xfs_buf *bp, - uint first, - uint last) -{ - struct xfs_buf_log_item *bip = bp->b_log_item; - - ASSERT((first <= last) && (last < bp->b_bcount)); - - xfs_trans_dirty_buf(tp, bp); - xfs_buf_item_log(bip, first, last); -} - -/* - * For userspace, ordered buffers just need to be marked dirty so - * the transaction commit will write them and mark them up-to-date. - * In essence, they are just like any other logged buffer in userspace. - * - * If the buffer is already dirty, trigger the "already logged" return condition. - */ -bool -libxfs_trans_ordered_buf( - struct xfs_trans *tp, - struct xfs_buf *bp) -{ - struct xfs_buf_log_item *bip = bp->b_log_item; - bool ret; - - ret = test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); - libxfs_trans_log_buf(tp, bp, 0, bp->b_bcount); - return ret; -} - static void xfs_buf_item_put( struct xfs_buf_log_item *bip) @@ -414,63 +340,7 @@ xfs_buf_item_put( kmem_zone_free(xfs_buf_item_zone, bip); } -void -libxfs_trans_brelse( - xfs_trans_t *tp, - xfs_buf_t *bp) -{ - xfs_buf_log_item_t *bip; - - if (tp == NULL) { - ASSERT(bp->b_transp == NULL); - libxfs_putbuf(bp); - return; - } - - trace_xfs_trans_brelse(bip); - ASSERT(bp->b_transp == tp); - bip = bp->b_log_item; - ASSERT(bip->bli_item.li_type == XFS_LI_BUF); - if (bip->bli_recur > 0) { - bip->bli_recur--; - return; - } - /* If dirty/stale, can't release till transaction committed */ - if (bip->bli_flags & XFS_BLI_STALE) - return; - if (test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags)) - return; - xfs_trans_del_item(&bip->bli_item); - if (bip->bli_flags & XFS_BLI_HOLD) - bip->bli_flags &= ~XFS_BLI_HOLD; - xfs_buf_item_put(bip); - bp->b_transp = NULL; - libxfs_putbuf(bp); -} - -void -libxfs_trans_binval( - xfs_trans_t *tp, - xfs_buf_t *bp) -{ - xfs_buf_log_item_t *bip = bp->b_log_item; - - ASSERT(bp->b_transp == tp); - ASSERT(bip != NULL); - - trace_xfs_trans_binval(bip); - - if (bip->bli_flags & XFS_BLI_STALE) - return; - XFS_BUF_UNDELAYWRITE(bp); - xfs_buf_stale(bp); - bip->bli_flags |= XFS_BLI_STALE; - bip->bli_flags &= ~XFS_BLI_DIRTY; - bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; - bip->__bli_format.blf_flags |= XFS_BLF_CANCEL; - set_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); - tp->t_flags |= XFS_TRANS_DIRTY; -} +/* from xfs_trans_buf.c */ /* * Add the locked buffer to the transaction. @@ -519,20 +389,6 @@ libxfs_trans_bjoin( trace_xfs_trans_bjoin(bp->b_log_item); } -void -libxfs_trans_bhold( - xfs_trans_t *tp, - xfs_buf_t *bp) -{ - xfs_buf_log_item_t *bip = bp->b_log_item; - - ASSERT(bp->b_transp == tp); - ASSERT(bip != NULL); - - bip->bli_flags |= XFS_BLI_HOLD; - trace_xfs_trans_bhold(bip); -} - xfs_buf_t * libxfs_trans_get_buf_map( xfs_trans_t *tp, @@ -651,6 +507,160 @@ out_relse: return error; } +void +libxfs_trans_brelse( + xfs_trans_t *tp, + xfs_buf_t *bp) +{ + xfs_buf_log_item_t *bip; + + if (tp == NULL) { + ASSERT(bp->b_transp == NULL); + libxfs_putbuf(bp); + return; + } + + trace_xfs_trans_brelse(bip); + ASSERT(bp->b_transp == tp); + bip = bp->b_log_item; + ASSERT(bip->bli_item.li_type == XFS_LI_BUF); + if (bip->bli_recur > 0) { + bip->bli_recur--; + return; + } + /* If dirty/stale, can't release till transaction committed */ + if (bip->bli_flags & XFS_BLI_STALE) + return; + if (test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags)) + return; + xfs_trans_del_item(&bip->bli_item); + if (bip->bli_flags & XFS_BLI_HOLD) + bip->bli_flags &= ~XFS_BLI_HOLD; + xfs_buf_item_put(bip); + bp->b_transp = NULL; + libxfs_putbuf(bp); +} + +/* + * Mark the buffer as not needing to be unlocked when the buf item's + * iop_unlock() routine is called. The buffer must already be locked + * and associated with the given transaction. + */ +/* ARGSUSED */ +void +libxfs_trans_bhold( + xfs_trans_t *tp, + xfs_buf_t *bp) +{ + xfs_buf_log_item_t *bip = bp->b_log_item; + + ASSERT(bp->b_transp == tp); + ASSERT(bip != NULL); + + bip->bli_flags |= XFS_BLI_HOLD; + trace_xfs_trans_bhold(bip); +} + +/* + * Mark a buffer dirty in the transaction. + */ +void +libxfs_trans_dirty_buf( + struct xfs_trans *tp, + struct xfs_buf *bp) +{ + struct xfs_buf_log_item *bip = bp->b_log_item; + + ASSERT(bp->b_transp == tp); + ASSERT(bip != NULL); + + tp->t_flags |= XFS_TRANS_DIRTY; + set_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); +} + +/* + * This is called to mark bytes first through last inclusive of the given + * buffer as needing to be logged when the transaction is committed. + * The buffer must already be associated with the given transaction. + * + * First and last are numbers relative to the beginning of this buffer, + * so the first byte in the buffer is numbered 0 regardless of the + * value of b_blkno. + */ +void +libxfs_trans_log_buf( + struct xfs_trans *tp, + struct xfs_buf *bp, + uint first, + uint last) +{ + struct xfs_buf_log_item *bip = bp->b_log_item; + + ASSERT((first <= last) && (last < bp->b_bcount)); + + xfs_trans_dirty_buf(tp, bp); + xfs_buf_item_log(bip, first, last); +} + +void +libxfs_trans_binval( + xfs_trans_t *tp, + xfs_buf_t *bp) +{ + xfs_buf_log_item_t *bip = bp->b_log_item; + + ASSERT(bp->b_transp == tp); + ASSERT(bip != NULL); + + trace_xfs_trans_binval(bip); + + if (bip->bli_flags & XFS_BLI_STALE) + return; + XFS_BUF_UNDELAYWRITE(bp); + xfs_buf_stale(bp); + bip->bli_flags |= XFS_BLI_STALE; + bip->bli_flags &= ~XFS_BLI_DIRTY; + bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; + bip->__bli_format.blf_flags |= XFS_BLF_CANCEL; + set_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); + tp->t_flags |= XFS_TRANS_DIRTY; +} + +void +libxfs_trans_inode_alloc_buf( + xfs_trans_t *tp, + xfs_buf_t *bp) +{ + xfs_buf_log_item_t *bip = bp->b_log_item; + + ASSERT(bp->b_transp == tp); + ASSERT(bip != NULL); + bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF; + xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF); +} + +/* + * For userspace, ordered buffers just need to be marked dirty so + * the transaction commit will write them and mark them up-to-date. + * In essence, they are just like any other logged buffer in userspace. + * + * If the buffer is already dirty, trigger the "already logged" return condition. + */ +bool +libxfs_trans_ordered_buf( + struct xfs_trans *tp, + struct xfs_buf *bp) +{ + struct xfs_buf_log_item *bip = bp->b_log_item; + bool ret; + + ret = test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags); + libxfs_trans_log_buf(tp, bp, 0, bp->b_bcount); + return ret; +} + +/* end of xfs_trans_buf.c */ + /* * Record the indicated change to the given field for application * to the file system's superblock when the transaction commits. From patchwork Fri Jul 12 21:36:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11042707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FDDF1395 for ; Fri, 12 Jul 2019 21:36:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D0442846C for ; Fri, 12 Jul 2019 21:36:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CC6228477; Fri, 12 Jul 2019 21:36:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0717A2846C for ; Fri, 12 Jul 2019 21:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728075AbfGLVga (ORCPT ); Fri, 12 Jul 2019 17:36:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbfGLVga (ORCPT ); Fri, 12 Jul 2019 17:36:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECC8681E07 for ; Fri, 12 Jul 2019 21:36:29 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C111819C67 for ; Fri, 12 Jul 2019 21:36:29 +0000 (UTC) Subject: [PATCH 2/4] xfsprogs: cosmetic changes to libxfs/trans.c To: linux-xfs References: From: Eric Sandeen Message-ID: <5c8fe68f-c5dd-4f23-de03-fa886cd57641@redhat.com> Date: Fri, 12 Jul 2019 16:36:29 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 12 Jul 2019 21:36:29 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make some completely trivial changes to libxfs/trans.c to more closely match kernelspace xfs_trans.c: - remove some typedefs - alter whitespace - rename some variables No functional changes. Signed-off-by: Eric Sandeen Reviewed-by: Carlos Maiolino diff --git a/libxfs/trans.c b/libxfs/trans.c index 8954f0fe..fecefc7a 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -361,7 +361,7 @@ _libxfs_trans_bjoin( ASSERT(bp->b_transp == NULL); - /* + /* * The xfs_buf_log_item pointer is stored in b_log_item. If * it doesn't have one yet, then allocate one and initialize it. * The checks to see if one is there are in xfs_buf_item_init(). @@ -389,21 +389,21 @@ libxfs_trans_bjoin( trace_xfs_trans_bjoin(bp->b_log_item); } -xfs_buf_t * +struct xfs_buf * libxfs_trans_get_buf_map( - xfs_trans_t *tp, - struct xfs_buftarg *btp, + struct xfs_trans *tp, + struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, - uint f) + uint flags) { xfs_buf_t *bp; - xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip; if (tp == NULL) - return libxfs_getbuf_map(btp, map, nmaps, 0); + return libxfs_getbuf_map(target, map, nmaps, 0); - bp = xfs_trans_buf_item_match(tp, btp, map, nmaps); + bp = xfs_trans_buf_item_match(tp, target, map, nmaps); if (bp != NULL) { ASSERT(bp->b_transp == tp); bip = bp->b_log_item; @@ -412,7 +412,7 @@ libxfs_trans_get_buf_map( return bp; } - bp = libxfs_getbuf_map(btp, map, nmaps, 0); + bp = libxfs_getbuf_map(target, map, nmaps, 0); if (bp == NULL) return NULL; @@ -424,11 +424,11 @@ libxfs_trans_get_buf_map( xfs_buf_t * libxfs_trans_getsb( xfs_trans_t *tp, - xfs_mount_t *mp, + struct xfs_mount *mp, int flags) { xfs_buf_t *bp; - xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip; int len = XFS_FSS_TO_BB(mp, 1); DEFINE_SINGLE_BUF_MAP(map, XFS_SB_DADDR, len); @@ -454,23 +454,23 @@ libxfs_trans_getsb( int libxfs_trans_read_buf_map( - xfs_mount_t *mp, - xfs_trans_t *tp, - struct xfs_buftarg *btp, + struct xfs_mount *mp, + struct xfs_trans *tp, + struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, uint flags, - xfs_buf_t **bpp, + struct xfs_buf **bpp, const struct xfs_buf_ops *ops) { - xfs_buf_t *bp; - xfs_buf_log_item_t *bip; + struct xfs_buf *bp; + struct xfs_buf_log_item *bip; int error; *bpp = NULL; if (tp == NULL) { - bp = libxfs_readbuf_map(btp, map, nmaps, flags, ops); + bp = libxfs_readbuf_map(target, map, nmaps, flags, ops); if (!bp) { return (flags & XBF_TRYLOCK) ? -EAGAIN : -ENOMEM; } @@ -479,7 +479,7 @@ libxfs_trans_read_buf_map( goto done; } - bp = xfs_trans_buf_item_match(tp, btp, map, nmaps); + bp = xfs_trans_buf_item_match(tp, target, map, nmaps); if (bp != NULL) { ASSERT(bp->b_transp == tp); ASSERT(bp->b_log_item != NULL); @@ -489,7 +489,7 @@ libxfs_trans_read_buf_map( goto done; } - bp = libxfs_readbuf_map(btp, map, nmaps, flags, ops); + bp = libxfs_readbuf_map(target, map, nmaps, flags, ops); if (!bp) { return (flags & XBF_TRYLOCK) ? -EAGAIN : -ENOMEM; } @@ -509,10 +509,10 @@ out_relse: void libxfs_trans_brelse( - xfs_trans_t *tp, - xfs_buf_t *bp) + struct xfs_trans *tp, + struct xfs_buf *bp) { - xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip; if (tp == NULL) { ASSERT(bp->b_transp == NULL); @@ -524,19 +524,23 @@ libxfs_trans_brelse( ASSERT(bp->b_transp == tp); bip = bp->b_log_item; ASSERT(bip->bli_item.li_type == XFS_LI_BUF); + if (bip->bli_recur > 0) { bip->bli_recur--; return; } + /* If dirty/stale, can't release till transaction committed */ if (bip->bli_flags & XFS_BLI_STALE) return; if (test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags)) return; + xfs_trans_del_item(&bip->bli_item); if (bip->bli_flags & XFS_BLI_HOLD) bip->bli_flags &= ~XFS_BLI_HOLD; xfs_buf_item_put(bip); + bp->b_transp = NULL; libxfs_putbuf(bp); } @@ -552,7 +556,7 @@ libxfs_trans_bhold( xfs_trans_t *tp, xfs_buf_t *bp) { - xfs_buf_log_item_t *bip = bp->b_log_item; + struct xfs_buf_log_item *bip = bp->b_log_item; ASSERT(bp->b_transp == tp); ASSERT(bip != NULL); @@ -599,6 +603,7 @@ libxfs_trans_log_buf( ASSERT((first <= last) && (last < bp->b_bcount)); xfs_trans_dirty_buf(tp, bp); + xfs_buf_item_log(bip, first, last); } @@ -607,7 +612,7 @@ libxfs_trans_binval( xfs_trans_t *tp, xfs_buf_t *bp) { - xfs_buf_log_item_t *bip = bp->b_log_item; + struct xfs_buf_log_item *bip = bp->b_log_item; ASSERT(bp->b_transp == tp); ASSERT(bip != NULL); @@ -618,6 +623,7 @@ libxfs_trans_binval( return; XFS_BUF_UNDELAYWRITE(bp); xfs_buf_stale(bp); + bip->bli_flags |= XFS_BLI_STALE; bip->bli_flags &= ~XFS_BLI_DIRTY; bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; @@ -631,7 +637,7 @@ libxfs_trans_inode_alloc_buf( xfs_trans_t *tp, xfs_buf_t *bp) { - xfs_buf_log_item_t *bip = bp->b_log_item; + struct xfs_buf_log_item *bip = bp->b_log_item; ASSERT(bp->b_transp == tp); ASSERT(bip != NULL); From patchwork Fri Jul 12 21:38:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11042709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53FA51395 for ; Fri, 12 Jul 2019 21:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3511C1FFE5 for ; Fri, 12 Jul 2019 21:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 253C828475; Fri, 12 Jul 2019 21:38:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FCFE1FFE5 for ; Fri, 12 Jul 2019 21:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbfGLVio (ORCPT ); Fri, 12 Jul 2019 17:38:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728079AbfGLVin (ORCPT ); Fri, 12 Jul 2019 17:38:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 320D1308FC4E for ; Fri, 12 Jul 2019 21:38:43 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 020305D739 for ; Fri, 12 Jul 2019 21:38:42 +0000 (UTC) Subject: [PATCH 3/4] xfsprogs: trivial changes to libxfs/trans.c To: linux-xfs References: From: Eric Sandeen Message-ID: <614554f7-2e1a-775e-0828-50b1307f1f09@redhat.com> Date: Fri, 12 Jul 2019 16:38:42 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 12 Jul 2019 21:38:43 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make some mostly trivial changes to libxfs/trans.c to more closely match kernelspace xfs_trans.c, including: - add tracepoint calls - add comments - add braces - change tests for null - reorder some tests and initializations This /should/ be no functional changes. Signed-off-by: Eric Sandeen Reviewed-by: Carlos Maiolino diff --git a/include/xfs_trace.h b/include/xfs_trace.h index 43720040..71a7466e 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -168,6 +168,8 @@ #define trace_xfs_trans_bjoin(a) ((void) 0) #define trace_xfs_trans_bhold(a) ((void) 0) #define trace_xfs_trans_get_buf(a) ((void) 0) +#define trace_xfs_trans_get_buf_recur(a) ((void) 0) +#define trace_xfs_trans_log_buf(a) ((void) 0) #define trace_xfs_trans_getsb_recur(a) ((void) 0) #define trace_xfs_trans_getsb(a) ((void) 0) #define trace_xfs_trans_read_buf_recur(a) ((void) 0) diff --git a/libxfs/trans.c b/libxfs/trans.c index fecefc7a..453e5476 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -389,6 +389,15 @@ libxfs_trans_bjoin( trace_xfs_trans_bjoin(bp->b_log_item); } +/* + * 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. + */ struct xfs_buf * libxfs_trans_get_buf_map( struct xfs_trans *tp, @@ -400,21 +409,31 @@ libxfs_trans_get_buf_map( xfs_buf_t *bp; struct xfs_buf_log_item *bip; - if (tp == NULL) + if (!tp) return libxfs_getbuf_map(target, map, nmaps, 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. 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, map, nmaps); if (bp != NULL) { ASSERT(bp->b_transp == tp); bip = bp->b_log_item; ASSERT(bip != NULL); bip->bli_recur++; + trace_xfs_trans_get_buf_recur(bip); return bp; } bp = libxfs_getbuf_map(target, map, nmaps, 0); - if (bp == NULL) + if (bp == NULL) { return NULL; + } + + ASSERT(!bp->b_error); _libxfs_trans_bjoin(tp, bp, 1); trace_xfs_trans_get_buf(bp->b_log_item); @@ -446,6 +465,8 @@ libxfs_trans_getsb( } bp = libxfs_getsb(mp, flags); + if (bp == NULL) + return NULL; _libxfs_trans_bjoin(tp, bp, 1); trace_xfs_trans_getsb(bp->b_log_item); @@ -480,7 +501,7 @@ libxfs_trans_read_buf_map( } bp = xfs_trans_buf_item_match(tp, target, map, nmaps); - if (bp != NULL) { + if (bp) { ASSERT(bp->b_transp == tp); ASSERT(bp->b_log_item != NULL); bip = bp->b_log_item; @@ -507,38 +528,61 @@ out_relse: return error; } +/* + * Release a buffer previously joined to the transaction. If the buffer is + * modified within this transaction, decrement the recursion count but do not + * release the buffer even if the count goes to 0. If the buffer is not modified + * within the transaction, decrement the recursion count and release the buffer + * if the recursion count goes to 0. + * + * If the buffer is to be released and it was not already dirty before this + * transaction began, then also free the buf_log_item associated with it. + * + * If the transaction pointer is NULL, this is a normal xfs_buf_relse() call. + */ void libxfs_trans_brelse( struct xfs_trans *tp, struct xfs_buf *bp) { - struct xfs_buf_log_item *bip; + struct xfs_buf_log_item *bip = bp->b_log_item; - if (tp == NULL) { - ASSERT(bp->b_transp == NULL); + ASSERT(bp->b_transp == tp); + + if (!tp) { libxfs_putbuf(bp); return; } trace_xfs_trans_brelse(bip); - ASSERT(bp->b_transp == tp); - bip = bp->b_log_item; ASSERT(bip->bli_item.li_type == XFS_LI_BUF); + /* + * If the release is for a recursive lookup, then decrement the count + * and return. + */ if (bip->bli_recur > 0) { bip->bli_recur--; return; } - /* If dirty/stale, can't release till transaction committed */ - if (bip->bli_flags & XFS_BLI_STALE) - return; + /* + * If the buffer is invalidated or dirty in this transaction, we can't + * release it until we commit. + */ if (test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags)) return; + if (bip->bli_flags & XFS_BLI_STALE) + return; + /* + * Unlink the log item from the transaction and clear the hold flag, if + * set. We wouldn't want the next user of the buffer to get confused. + */ xfs_trans_del_item(&bip->bli_item); - if (bip->bli_flags & XFS_BLI_HOLD) - bip->bli_flags &= ~XFS_BLI_HOLD; + bip->bli_flags &= ~XFS_BLI_HOLD; + + /* drop the reference to the bli */ xfs_buf_item_put(bip); bp->b_transp = NULL; @@ -600,10 +644,11 @@ libxfs_trans_log_buf( { struct xfs_buf_log_item *bip = bp->b_log_item; - ASSERT((first <= last) && (last < bp->b_bcount)); + ASSERT(first <= last && last < BBTOB(bp->b_length)); xfs_trans_dirty_buf(tp, bp); + trace_xfs_trans_log_buf(bip); xfs_buf_item_log(bip, first, last); } @@ -632,6 +677,15 @@ libxfs_trans_binval( tp->t_flags |= XFS_TRANS_DIRTY; } +/* + * Mark the buffer as being one which contains newly allocated + * inodes. We need to make sure that even if this buffer is + * relogged as an 'inode buf' we still recover all of the inode + * images in the face of a crash. This works in coordination with + * xfs_buf_item_committed() to ensure that the buffer remains in the + * AIL at its original location even after it has been relogged. + */ +/* ARGSUSED */ void libxfs_trans_inode_alloc_buf( xfs_trans_t *tp, From patchwork Fri Jul 12 21:46:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11042711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96F10912 for ; Fri, 12 Jul 2019 21:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7744027F3E for ; Fri, 12 Jul 2019 21:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6493A28475; Fri, 12 Jul 2019 21:55:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E808427F3E for ; Fri, 12 Jul 2019 21:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbfGLVzC (ORCPT ); Fri, 12 Jul 2019 17:55:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52044 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbfGLVzC (ORCPT ); Fri, 12 Jul 2019 17:55:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFEF1308620F for ; Fri, 12 Jul 2019 21:46:59 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B74E91001B17 for ; Fri, 12 Jul 2019 21:46:59 +0000 (UTC) Subject: [PATCH 4/4] xfsprogs: don't use enum for buffer flags To: linux-xfs References: From: Eric Sandeen Message-ID: <9a4275dd-3e33-1fbb-efd4-57db6f646bff@redhat.com> Date: Fri, 12 Jul 2019 16:46:59 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 12 Jul 2019 21:46:59 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This roughly mirrors 807cbbdb xfs: do not use emums for flags used in tracing and lets us use the xfs_buf_flags_t type in function calls as is done in the kernel. Signed-off-by: Eric Sandeen Reviewed-by: Carlos Maiolino diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 60e1dbdb..926fe102 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -107,12 +107,12 @@ bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps, - uint flags); + xfs_buf_flags_t flags); int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps, - uint flags, struct xfs_buf **bpp, + xfs_buf_flags_t flags, struct xfs_buf **bpp, const struct xfs_buf_ops *ops); static inline struct xfs_buf * libxfs_trans_get_buf( @@ -133,7 +133,7 @@ libxfs_trans_read_buf( struct xfs_buftarg *btp, xfs_daddr_t blkno, int numblks, - uint flags, + xfs_buf_flags_t flags, struct xfs_buf **bpp, const struct xfs_buf_ops *ops) { diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 79ffd470..e09dd849 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -81,14 +81,15 @@ typedef struct xfs_buf { bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic); bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic); -enum xfs_buf_flags_t { /* b_flags bits */ - LIBXFS_B_EXIT = 0x0001, /* ==LIBXFS_EXIT_ON_FAILURE */ - LIBXFS_B_DIRTY = 0x0002, /* buffer has been modified */ - LIBXFS_B_STALE = 0x0004, /* buffer marked as invalid */ - LIBXFS_B_UPTODATE = 0x0008, /* buffer is sync'd to disk */ - LIBXFS_B_DISCONTIG = 0x0010, /* discontiguous buffer */ - LIBXFS_B_UNCHECKED = 0x0020, /* needs verification */ -}; +/* b_flags bits */ +#define LIBXFS_B_EXIT 0x0001 /* ==LIBXFS_EXIT_ON_FAILURE */ +#define LIBXFS_B_DIRTY 0x0002 /* buffer has been modified */ +#define LIBXFS_B_STALE 0x0004 /* buffer marked as invalid */ +#define LIBXFS_B_UPTODATE 0x0008 /* buffer is sync'd to disk */ +#define LIBXFS_B_DISCONTIG 0x0010 /* discontiguous buffer */ +#define LIBXFS_B_UNCHECKED 0x0020 /* needs verification */ + +typedef unsigned int xfs_buf_flags_t; #define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) diff --git a/libxfs/trans.c b/libxfs/trans.c index 453e5476..faf36daa 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -404,7 +404,7 @@ libxfs_trans_get_buf_map( struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, - uint flags) + xfs_buf_flags_t flags) { xfs_buf_t *bp; struct xfs_buf_log_item *bip; @@ -480,7 +480,7 @@ libxfs_trans_read_buf_map( struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, - uint flags, + xfs_buf_flags_t flags, struct xfs_buf **bpp, const struct xfs_buf_ops *ops) {