From patchwork Mon Mar 17 05:48:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018677 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6A2379D2 for ; Mon, 17 Mar 2025 05:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190538; cv=none; b=kPAGMaVC4j2beXatYA/5Pj51mVba5vCDPY7l5t4iHy0VsrWKWNkVZjWTxJS7iuC9azKBaA6bGEi2c+3DVNbWMeeN0+iZyNI49oR5g1xkOaBhIQ90JkSKfkFo3cL86yxWx9UnDM+SrHjr0ZrjWS8/He1+AV+Or4EHLYfapuOmrbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190538; c=relaxed/simple; bh=XGplgajrW/SCs2w7VsPa4e9FE24Kd59vwE4G0NzkEPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CYFhpG8G3FFtCx8Az1pDfOXH9DdkE902enZwZ53Fp4wlGrc0LRJbEkNdWWeLMSZbSqirSePTCoHHTFVJFCY4mORuq3wnCFBP674ABGPKuJfk6Hh95W7NK9npS09xF95TTR+JblEhRSIXaU8hhjsv0g2ty7cnbV4pfCibuPjXuqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=w6V0C1lw; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="w6V0C1lw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QQAW/mEgZikIpbo+X4T7ENxp99nVvGFkxe13f2Pzy3k=; b=w6V0C1lwVBxrg+J5GaRlCvVNi9 Ag8+F973dWGQORnRBztIqGFmyCPdwwwkjDz/kd0QoiRdG/3XiQ9gqi0lTdKkvcOFGn5WRet6lUx3G yw9KYudBfHyWSGuw3iie3ZQkzJY4+0QLHthdoDLkmJ9UfqUW2Y72OGdLH5YYO82RxyoYcUkRfdRZr ZcGMOFbhGudD9ZFrvjuEbmTa7MRfytEpiz+3SHFHCwkNGKffZobUksy8kAZOnYk/pxnT2eLl0rus+ cP+uydMJulqAs2ovVLZQvbPMB9CvxRmbHJW9IzEwFVdfZ76CcMdksGgSeTCMQ018OdkyRJQH9I2xE DB+PC5Uw==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3LL-00000001Ini-41K5; Mon, 17 Mar 2025 05:48:56 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 1/5] xfs: call xfs_buf_alloc_backing_mem from _xfs_buf_alloc Date: Mon, 17 Mar 2025 06:48:32 +0100 Message-ID: <20250317054850.1132557-2-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054850.1132557-1-hch@lst.de> References: <20250317054850.1132557-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html We never allocate a buffer without backing memory. Simplify the call chain by calling xfs_buf_alloc_backing_mem from _xfs_buf_alloc. To avoid a forward declaration, move _xfs_buf_alloc down a bit in the file. Also drop the pointless _-prefix from _xfs_buf_alloc. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_buf.c | 165 +++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 90 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 106ee81fa56f..f42f6e47f783 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -118,71 +118,6 @@ xfs_buf_free_maps( } } -static int -_xfs_buf_alloc( - struct xfs_buftarg *target, - struct xfs_buf_map *map, - int nmaps, - xfs_buf_flags_t flags, - struct xfs_buf **bpp) -{ - struct xfs_buf *bp; - int error; - int i; - - *bpp = NULL; - bp = kmem_cache_zalloc(xfs_buf_cache, - GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); - - /* - * We don't want certain flags to appear in b_flags unless they are - * specifically set by later operations on the buffer. - */ - flags &= ~(XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD); - - /* - * A new buffer is held and locked by the owner. This ensures that the - * buffer is owned by the caller and racing RCU lookups right after - * inserting into the hash table are safe (and will have to wait for - * the unlock to do anything non-trivial). - */ - bp->b_hold = 1; - sema_init(&bp->b_sema, 0); /* held, no waiters */ - - spin_lock_init(&bp->b_lock); - atomic_set(&bp->b_lru_ref, 1); - init_completion(&bp->b_iowait); - INIT_LIST_HEAD(&bp->b_lru); - INIT_LIST_HEAD(&bp->b_list); - INIT_LIST_HEAD(&bp->b_li_list); - bp->b_target = target; - bp->b_mount = target->bt_mount; - bp->b_flags = flags; - - error = xfs_buf_get_maps(bp, nmaps); - if (error) { - kmem_cache_free(xfs_buf_cache, bp); - return error; - } - - bp->b_rhash_key = map[0].bm_bn; - bp->b_length = 0; - for (i = 0; i < nmaps; i++) { - bp->b_maps[i].bm_bn = map[i].bm_bn; - bp->b_maps[i].bm_len = map[i].bm_len; - bp->b_length += map[i].bm_len; - } - - atomic_set(&bp->b_pin_count, 0); - init_waitqueue_head(&bp->b_waiters); - - XFS_STATS_INC(bp->b_mount, xb_create); - trace_xfs_buf_init(bp, _RET_IP_); - - *bpp = bp; - return 0; -} - static void xfs_buf_free_callback( struct callback_head *cb) @@ -342,6 +277,77 @@ xfs_buf_alloc_backing_mem( return 0; } +static int +xfs_buf_alloc( + struct xfs_buftarg *target, + struct xfs_buf_map *map, + int nmaps, + xfs_buf_flags_t flags, + struct xfs_buf **bpp) +{ + struct xfs_buf *bp; + int error; + int i; + + *bpp = NULL; + bp = kmem_cache_zalloc(xfs_buf_cache, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); + + /* + * We don't want certain flags to appear in b_flags unless they are + * specifically set by later operations on the buffer. + */ + flags &= ~(XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD); + + /* + * A new buffer is held and locked by the owner. This ensures that the + * buffer is owned by the caller and racing RCU lookups right after + * inserting into the hash table are safe (and will have to wait for + * the unlock to do anything non-trivial). + */ + bp->b_hold = 1; + sema_init(&bp->b_sema, 0); /* held, no waiters */ + + spin_lock_init(&bp->b_lock); + atomic_set(&bp->b_lru_ref, 1); + init_completion(&bp->b_iowait); + INIT_LIST_HEAD(&bp->b_lru); + INIT_LIST_HEAD(&bp->b_list); + INIT_LIST_HEAD(&bp->b_li_list); + bp->b_target = target; + bp->b_mount = target->bt_mount; + bp->b_flags = flags; + + error = xfs_buf_get_maps(bp, nmaps); + if (error) { + kmem_cache_free(xfs_buf_cache, bp); + return error; + } + + bp->b_rhash_key = map[0].bm_bn; + bp->b_length = 0; + for (i = 0; i < nmaps; i++) { + bp->b_maps[i].bm_bn = map[i].bm_bn; + bp->b_maps[i].bm_len = map[i].bm_len; + bp->b_length += map[i].bm_len; + } + + atomic_set(&bp->b_pin_count, 0); + init_waitqueue_head(&bp->b_waiters); + + XFS_STATS_INC(bp->b_mount, xb_create); + trace_xfs_buf_init(bp, _RET_IP_); + + error = xfs_buf_alloc_backing_mem(bp, flags); + if (error) { + xfs_buf_free(bp); + return error; + } + + *bpp = bp; + return 0; +} + /* * Finding and Reading Buffers */ @@ -525,14 +531,10 @@ xfs_buf_find_insert( struct xfs_buf *bp; int error; - error = _xfs_buf_alloc(btp, map, nmaps, flags, &new_bp); + error = xfs_buf_alloc(btp, map, nmaps, flags, &new_bp); if (error) goto out_drop_pag; - error = xfs_buf_alloc_backing_mem(new_bp, flags); - if (error) - goto out_free_buf; - /* The new buffer keeps the perag reference until it is freed. */ new_bp->b_pag = pag; @@ -869,28 +871,11 @@ xfs_buf_get_uncached( struct xfs_buf **bpp) { int error; - struct xfs_buf *bp; DEFINE_SINGLE_BUF_MAP(map, XFS_BUF_DADDR_NULL, numblks); - /* there are currently no valid flags for xfs_buf_get_uncached */ - ASSERT(flags == 0); - - *bpp = NULL; - - error = _xfs_buf_alloc(target, &map, 1, flags, &bp); - if (error) - return error; - - error = xfs_buf_alloc_backing_mem(bp, flags); - if (error) - goto fail_free_buf; - - trace_xfs_buf_get_uncached(bp, _RET_IP_); - *bpp = bp; - return 0; - -fail_free_buf: - xfs_buf_free(bp); + error = xfs_buf_alloc(target, &map, 1, flags, bpp); + if (!error) + trace_xfs_buf_get_uncached(*bpp, _RET_IP_); return error; } From patchwork Mon Mar 17 05:48:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018678 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00E0C218AA3 for ; Mon, 17 Mar 2025 05:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190541; cv=none; b=sbclQx9m33+cUvmt8kWWihoxzW43UBONrb2iDKKbqBJQYbXn5xbwhrvtXhxU28KDIacJySTXdqo6TWR4Jt+Ichy33bKI7+g2GrNWNoA0CRI9Y4Xrt8whzrYo4W8da192mLbpbcHRwjaNoqiNwD7zXdj/OFkIVR5FWRIiT0osUdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190541; c=relaxed/simple; bh=//LM7jjQnUAaWqyjNSeh9VDblxyGe3aj+NYJUg3IQ2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gABEl88VhctHEEkO1mQ5ifRF4uoIhAzVNl3uTzgJlJn/gOTsSDWSCga6P4x7cdgm6+fbo+FRuwgodM3rhk6+dVfYco8qipiHRVt2ZHKfdEeLxW2w/e2xHzjC185RzsznEVI72LIGxaW0h6ti8nRuQE1lqEHNKuepGMzx/bYuSiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=SFKMi9Tt; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SFKMi9Tt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=qR277G8WDBq2PbF1kAry2DjkDCOky1J5eydA3MAbvzQ=; b=SFKMi9Tt26zhiIanMNNp4G+Azd ccPbIRbvmRdKAJBQK4Arbj68p7Dloh1VFhe8JFk1z7ZH2CmNkEnOl5RBXqgz+3JV1SpcGCJN7cFPX Swgl8YekZIFg5Rn3NwhJERXUHVzvTLbjEZcQdGWM5v1gRAv0S2JheuwbuKSCYKWUqEmzfEazbvNej nM2LG17N2S9suKIxETgZs3zrqCP596uoYcggaX2BS5GlC1lBmnvjZunty66xwmOLeqWpM7hh83wWS YRPhyu8DKQCdHy/WmAB64KMeG64Avw7EtEaBLGkhdM1VkmHoi++crCbdz+GiSIZMhoU0DmNwyM7yJ UwtkhkVw==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3LO-00000001Ins-4C8f; Mon, 17 Mar 2025 05:48:59 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 2/5] xfs: remove xfs_buf_get_maps Date: Mon, 17 Mar 2025 06:48:33 +0100 Message-ID: <20250317054850.1132557-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054850.1132557-1-hch@lst.de> References: <20250317054850.1132557-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_buf_get_maps has a single caller, and can just be open coded there. When doing that, stop handling the allocation failure as we always pass __GFP_NOFAIL to the slab allocator, and use the proper kcalloc helper for array allocations. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_buf.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index f42f6e47f783..878dc0f108d1 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -88,26 +88,6 @@ xfs_buf_stale( spin_unlock(&bp->b_lock); } -static int -xfs_buf_get_maps( - struct xfs_buf *bp, - int map_count) -{ - ASSERT(bp->b_maps == NULL); - bp->b_map_count = map_count; - - if (map_count == 1) { - bp->b_maps = &bp->__b_map; - return 0; - } - - bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map), - GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); - if (!bp->b_maps) - return -ENOMEM; - return 0; -} - static void xfs_buf_free_maps( struct xfs_buf *bp) @@ -317,15 +297,14 @@ xfs_buf_alloc( bp->b_target = target; bp->b_mount = target->bt_mount; bp->b_flags = flags; - - error = xfs_buf_get_maps(bp, nmaps); - if (error) { - kmem_cache_free(xfs_buf_cache, bp); - return error; - } - bp->b_rhash_key = map[0].bm_bn; bp->b_length = 0; + bp->b_map_count = nmaps; + if (nmaps == 1) + bp->b_maps = &bp->__b_map; + else + bp->b_maps = kcalloc(nmaps, sizeof(struct xfs_buf_map), + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); for (i = 0; i < nmaps; i++) { bp->b_maps[i].bm_bn = map[i].bm_bn; bp->b_maps[i].bm_len = map[i].bm_len; From patchwork Mon Mar 17 05:48:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018679 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83FE779D2 for ; Mon, 17 Mar 2025 05:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190544; cv=none; b=j512vGYOt7nDc8mGVUXO7YPlPREMXO2OchzuUsKit0vrDMFsc+6vYzond5S1yYxrHiU+AktjGaNB+jbi4fuVuLuK1eFAUHE35AktlBN/inFPNIj2dqh+Gt+oFFzyDnHMOuSoGU4m+p48qTvwBMW6XHPid7zQSDs43Z9i4wJhnG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190544; c=relaxed/simple; bh=Nm6C6igqpALv/wY3y/6yePARbyn/ZaTPgcSB1LsUvt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eVjevMSAVjRfKVuL/e9Rxahx00xZEIGTi3JGzNgYuegJgJ3n6vUckOQuoNsJDlKYlzvm0JXCC7kCU3tM8Ku0jLLpEttQZhIF5EvSCujcSrt1BdPVV+xlAcWnTyDTcBR1GlaiHmmqSh9m0sOaa58LVYllympYBHyaJBTKC/4bO+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=YXEHHkPe; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YXEHHkPe" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=xBH+WATQqlpbOQSvh+47ZY1UK+7Q04Lq57yGSNk4jeA=; b=YXEHHkPe4X/Byxqz5WuF1L7iR9 zF9dZRt04ntDlNNv4gdl6e7oToEYKjL6s2XmHHhlaTKKvQEsuZCjqzbfbupjpATM2/qVz4vuS2W2T iHWpXFjeF5kEJaNXDtcvP6WMEqzpmU1TDH8VZGqBhwkJzLbZrzhtMMOAvYN+IFHjqwo890WYCHT63 A3pF15OXKV8Qe/nIM+9ROUMy22LShgvo8NWgeC4saUdUvC311JtA/ag4XFTFDKVXuHeZ4uXBL6er+ +uuB2NqQo+DHwr5tQ7/PD2zlJ8ujNfhuXFDMhwcK/P9VpCoot8t/M8AG3RjM++2ZlPtVqyCONlk3l DOFautAA==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3LS-00000001IoH-2rEn; Mon, 17 Mar 2025 05:49:03 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 3/5] xfs: remove xfs_buf_free_maps Date: Mon, 17 Mar 2025 06:48:34 +0100 Message-ID: <20250317054850.1132557-4-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054850.1132557-1-hch@lst.de> References: <20250317054850.1132557-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_buf_free_maps only has a single caller, so open code it there. Stop zeroing the b_maps pointer as the buffer is freed in the next line. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_buf.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 878dc0f108d1..bf75964bbfe8 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -88,23 +88,14 @@ xfs_buf_stale( spin_unlock(&bp->b_lock); } -static void -xfs_buf_free_maps( - struct xfs_buf *bp) -{ - if (bp->b_maps != &bp->__b_map) { - kfree(bp->b_maps); - bp->b_maps = NULL; - } -} - static void xfs_buf_free_callback( struct callback_head *cb) { struct xfs_buf *bp = container_of(cb, struct xfs_buf, b_rcu); - xfs_buf_free_maps(bp); + if (bp->b_maps != &bp->__b_map) + kfree(bp->b_maps); kmem_cache_free(xfs_buf_cache, bp); } From patchwork Mon Mar 17 05:48:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018680 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2C6818C33B for ; Mon, 17 Mar 2025 05:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190549; cv=none; b=LYPnH3/pNPBc1OVE0gYcNZe6GU04y+Tv3tq5JbKhuKTh5YrDRBCSVTv4HOR0l+A/XE1csZIApRpw/e4HGpjN0/AAMjUGyXMIcYo29mV42L790s4Gu8dXzZTc1ba7e5sa4BCs0wCa3oxbos9bk2WiG2Sfqsgu6HHzQIbS/LG5wzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190549; c=relaxed/simple; bh=dW2HpItAVqEkwy7f8DrHeAaCzWiLCLKBWzvum2XhjbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AaKCS2FaFzDxT+WGkukpWuR/JVJHjMBm+Mw6TDWdzMEoM0DVvjxPRc64bAPg9mbcvKVQmqkp+MsP0cJixb3gQOf5h48C5+/5JW9JDbc+EWguEVNy12hzlQwaJsna2QdpUTbOOjhaapStEEzLxVNRgI9syGZLdMw951Xup2xAhmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=wALO3RTJ; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="wALO3RTJ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=tHSrUAa4jQhSdH96RwDas/FsSCOLFogmIVur0Z59fzU=; b=wALO3RTJOPfjBVubRh+hY5hKiC PnuGR8QkXEuwwPCTDl6duR2ksHtJFjV/IzdoHCZMMGpQHeJAzRLmUSZyK+jaJoAEwE7G1xEWVUdOe NfINBoM5FAflP0UQxKwdFlVuYxaeP/deUH6woZ7NCgpaRDWzwhhl6vn6QVqgMBXKoWdxxMn39LUev 4UhHbICdV77egSMmjZmQbm8AQ2aij7js3xrlSoccBz0pHZ3Mphs63A5dyumpnp/dlWGnMD4TXBJwa Eq4qJIxcHU7ucAsLVdgeBK+nXoWXqKKTSEBSFgbc4LiCe/n9nsW8A8VvQgDIoicifIsp7vJ7/+pDl 6AVmTpIQ==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3LW-00000001Ip1-2WLh; Mon, 17 Mar 2025 05:49:07 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 4/5] xfs: remove the flags argument to xfs_buf_read_uncached Date: Mon, 17 Mar 2025 06:48:35 +0100 Message-ID: <20250317054850.1132557-5-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054850.1132557-1-hch@lst.de> References: <20250317054850.1132557-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html No callers passes flags to xfs_buf_read_uncached, which makes sense given that the flags apply to behavior not used for uncached buffers. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_buf.c | 3 +-- fs/xfs/xfs_buf.h | 2 +- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_mount.c | 6 +++--- fs/xfs/xfs_rtalloc.c | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index bf75964bbfe8..6469a69b18fe 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -802,7 +802,6 @@ xfs_buf_read_uncached( struct xfs_buftarg *target, xfs_daddr_t daddr, size_t numblks, - xfs_buf_flags_t flags, struct xfs_buf **bpp, const struct xfs_buf_ops *ops) { @@ -811,7 +810,7 @@ xfs_buf_read_uncached( *bpp = NULL; - error = xfs_buf_get_uncached(target, numblks, flags, &bp); + error = xfs_buf_get_uncached(target, numblks, 0, &bp); if (error) return error; diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index db43bdc17f55..6a426a8d6197 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -275,7 +275,7 @@ xfs_buf_readahead( int xfs_buf_get_uncached(struct xfs_buftarg *target, size_t numblks, xfs_buf_flags_t flags, struct xfs_buf **bpp); int xfs_buf_read_uncached(struct xfs_buftarg *target, xfs_daddr_t daddr, - size_t numblks, xfs_buf_flags_t flags, struct xfs_buf **bpp, + size_t numblks, struct xfs_buf **bpp, const struct xfs_buf_ops *ops); int _xfs_buf_read(struct xfs_buf *bp); void xfs_buf_hold(struct xfs_buf *bp); diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index b6f3d7abdae5..0ada73569394 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -111,7 +111,7 @@ xfs_growfs_data_private( if (nb > mp->m_sb.sb_dblocks) { error = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), - XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); + XFS_FSS_TO_BB(mp, 1), &bp, NULL); if (error) return error; xfs_buf_relse(bp); diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index e65a659901d5..00b53f479ece 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -186,7 +186,7 @@ xfs_readsb( */ reread: error = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, - BTOBB(sector_size), 0, &bp, buf_ops); + BTOBB(sector_size), &bp, buf_ops); if (error) { if (loud) xfs_warn(mp, "SB validate failed with error %d.", error); @@ -414,7 +414,7 @@ xfs_check_sizes( } error = xfs_buf_read_uncached(mp->m_ddev_targp, d - XFS_FSS_TO_BB(mp, 1), - XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); + XFS_FSS_TO_BB(mp, 1), &bp, NULL); if (error) { xfs_warn(mp, "last sector read failed"); return error; @@ -431,7 +431,7 @@ xfs_check_sizes( } error = xfs_buf_read_uncached(mp->m_logdev_targp, d - XFS_FSB_TO_BB(mp, 1), - XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); + XFS_FSB_TO_BB(mp, 1), &bp, NULL); if (error) { xfs_warn(mp, "log device read failed"); return error; diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 3aa222ea9500..e35c728f222e 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1350,7 +1350,7 @@ xfs_rt_check_size( error = xfs_buf_read_uncached(mp->m_rtdev_targp, XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart) + daddr, - XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); + XFS_FSB_TO_BB(mp, 1), &bp, NULL); if (error) xfs_warn(mp, "cannot read last RT device sector (%lld)", last_block); @@ -1511,7 +1511,7 @@ xfs_rtmount_readsb( /* m_blkbb_log is not set up yet */ error = xfs_buf_read_uncached(mp->m_rtdev_targp, XFS_RTSB_DADDR, - mp->m_sb.sb_blocksize >> BBSHIFT, 0, &bp, + mp->m_sb.sb_blocksize >> BBSHIFT, &bp, &xfs_rtsb_buf_ops); if (error) { xfs_warn(mp, "rt sb validate failed with error %d.", error); From patchwork Mon Mar 17 05:48:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018681 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91423219A79 for ; Mon, 17 Mar 2025 05:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190552; cv=none; b=AnHvW1u8kqGAiPzL/ZxmOvToOdk9mslz2mZUtVo0MgYHr2dGdZp+rBivLjOIxAIA95XG4Ai54Wpca4mCGyX+wK+Hf8R+nj7cYc7iNqgTE9ovuK1m5V8Qmi70W/Rd1kD9HpMBguezh+zQgdr3miChz+Qr5mk+bB6KRnr9W/9VgVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190552; c=relaxed/simple; bh=fPmDTdfO/+jLAnCyNNaSuoWNPbeN3xe9ZkrqNMQH5Co=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TGiAvoE7RtPqcmiX8eI9U2VIBisH6eFjz/hyzLAK/uaZCGMYLVvpLI/jThEEoCmbnritDi+7Kzsq8nGaoaybGDwo0jKLZNOUh/6hUl3WWUOL7G6HUuQ/J+R814UA0WraBcd2EHXlVCRyGSfNbEyV2Q+6pIFreyp9wJgmDBQx1o8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ku+MvIKS; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ku+MvIKS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=tpAgpCh8XCRzIdJBx/rREKeqv7suLQPlYqpqfq9N6JU=; b=ku+MvIKShDr3sp2iIi4qMpAqni qy1xxA241qHEQvMzZK6sTtdRqM1jzLYmJrtzn0N+ro55326w8Yo/FvnKogxYBKtheCr4TKrgjXqXN QftnYIj5xGvw6F5vpJ8mHmJwegUV5lKArX+2czT39+L+GXmUTNeNkHf1OAPG/ke1Y8frZsJtVtIA/ XeE2uWlmIZOwXZVOAClaNt3wODWdmt3AmrXj/xYvUDGKjllu3ppjRA3Q1YHdRInCXLlucuAeTwn66 a1PA1vw5x9y7mBWAkELPJ3DSipkrgvw0QNSrO76ZgIXWjQzI+hTeQWFJ+FKI20nvX3jDSRDIAMfl2 CR6LIemw==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3La-00000001Iqc-2Por; Mon, 17 Mar 2025 05:49:11 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 5/5] xfs: remove the flags argument to xfs_buf_get_uncached Date: Mon, 17 Mar 2025 06:48:36 +0100 Message-ID: <20250317054850.1132557-6-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054850.1132557-1-hch@lst.de> References: <20250317054850.1132557-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html No callers passes flags to xfs_buf_get_uncached, which makes sense given that the flags apply to behavior not used for uncached buffers. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/libxfs/xfs_ag.c | 2 +- fs/xfs/xfs_buf.c | 5 ++--- fs/xfs/xfs_buf.h | 2 +- fs/xfs/xfs_rtalloc.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index b59cb461e096..e6ba914f6d06 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -301,7 +301,7 @@ xfs_get_aghdr_buf( struct xfs_buf *bp; int error; - error = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0, &bp); + error = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, &bp); if (error) return error; diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 6469a69b18fe..8e7f1b324b3b 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -810,7 +810,7 @@ xfs_buf_read_uncached( *bpp = NULL; - error = xfs_buf_get_uncached(target, numblks, 0, &bp); + error = xfs_buf_get_uncached(target, numblks, &bp); if (error) return error; @@ -836,13 +836,12 @@ int xfs_buf_get_uncached( struct xfs_buftarg *target, size_t numblks, - xfs_buf_flags_t flags, struct xfs_buf **bpp) { int error; DEFINE_SINGLE_BUF_MAP(map, XFS_BUF_DADDR_NULL, numblks); - error = xfs_buf_alloc(target, &map, 1, flags, bpp); + error = xfs_buf_alloc(target, &map, 1, 0, bpp); if (!error) trace_xfs_buf_get_uncached(*bpp, _RET_IP_); return error; diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 6a426a8d6197..d0b065a9a9f0 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -273,7 +273,7 @@ xfs_buf_readahead( } int xfs_buf_get_uncached(struct xfs_buftarg *target, size_t numblks, - xfs_buf_flags_t flags, struct xfs_buf **bpp); + struct xfs_buf **bpp); int xfs_buf_read_uncached(struct xfs_buftarg *target, xfs_daddr_t daddr, size_t numblks, struct xfs_buf **bpp, const struct xfs_buf_ops *ops); diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index e35c728f222e..6484c596ecea 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -839,7 +839,7 @@ xfs_growfs_rt_init_rtsb( return 0; error = xfs_buf_get_uncached(mp->m_rtdev_targp, XFS_FSB_TO_BB(mp, 1), - 0, &rtsb_bp); + &rtsb_bp); if (error) return error;