From patchwork Fri Aug 30 10:24:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11123709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 628171398 for ; Fri, 30 Aug 2019 10:24:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41B1721874 for ; Fri, 30 Aug 2019 10:24:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KmRKrM88" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727521AbfH3KYS (ORCPT ); Fri, 30 Aug 2019 06:24:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34678 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbfH3KYR (ORCPT ); Fri, 30 Aug 2019 06:24:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nd4/H5VkrAcBzF4aQIJMzKbM8nv5cEPWSBtHZ0JHfVA=; b=KmRKrM88FwbPjo6AZdPOghITs W8sLqW/eyYcqSnk69fX/or3h9PnVdFFUgPsTUhJ24gfyk+WhPCU1GTf3GQ5tb8onGIUtehdIgehrB fmR7qQnNgimfQ5zeap9j6PCeyfzxa4vRkDzm86jdF6zr0XtBNPf43wZVG7RK2TH2alrgS5T8T54eG 5aSxLmkr8tWPg4CwrtppMVmxXV0IP9tklJFJHtY6Kk6LyiRqD85P29XlwttcrMysIdQoBWd94wm92 70Auerd7Yo4kNfEJu41pI+oySthPM7BJRaZ5ZxUbbckm5vCS6qy6UT758uVLlVLeEmyDPnnjBvbGR UAUHqW3rQ==; Received: from [2001:4bb8:180:3f4c:863:2ead:e9d4:da9f] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i3e4m-0003oV-Qc for linux-xfs@vger.kernel.org; Fri, 30 Aug 2019 10:24:17 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 1/3] xfs: add a xfs_valid_startblock helper Date: Fri, 30 Aug 2019 12:24:09 +0200 Message-Id: <20190830102411.519-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190830102411.519-1-hch@lst.de> References: <20190830102411.519-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add a helper that validates the startblock is valid. This checks for a non-zero block on the main device, but skips that check for blocks on the realtime device. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_bmap.h | 3 +++ fs/xfs/xfs_iomap.c | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 05aedf4a538c..80b25e21e708 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4519,7 +4519,7 @@ xfs_bmapi_convert_delalloc( if (WARN_ON_ONCE(bma.blkno == NULLFSBLOCK)) goto out_finish; error = -EFSCORRUPTED; - if (WARN_ON_ONCE(!bma.got.br_startblock && !XFS_IS_REALTIME_INODE(ip))) + if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) goto out_finish; XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, bma.length)); diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index c409871a096e..7efa56e8750f 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -171,6 +171,9 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec) !isnullstartblock(irec->br_startblock); } +#define xfs_valid_startblock(ip, startblock) \ + ((startblock) != 0 || XFS_IS_REALTIME_INODE(ip)) + void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, xfs_filblks_t len); int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 3a4310d7cb59..f780e223b118 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -58,7 +58,7 @@ xfs_bmbt_to_iomap( { struct xfs_mount *mp = ip->i_mount; - if (unlikely(!imap->br_startblock && !XFS_IS_REALTIME_INODE(ip))) + if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) return xfs_alert_fsblock_zero(ip, imap); if (imap->br_startblock == HOLESTARTBLOCK) { @@ -297,7 +297,7 @@ xfs_iomap_write_direct( goto out_unlock; } - if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) + if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) error = xfs_alert_fsblock_zero(ip, imap); out_unlock: @@ -814,7 +814,7 @@ xfs_iomap_write_unwritten( if (error) return error; - if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) + if (unlikely(!xfs_valid_startblock(ip, imap.br_startblock))) return xfs_alert_fsblock_zero(ip, &imap); if ((numblks_fsb = imap.br_blockcount) == 0) { From patchwork Fri Aug 30 10:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11123711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44F9C1399 for ; Fri, 30 Aug 2019 10:24:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B9F521721 for ; Fri, 30 Aug 2019 10:24:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="eZw94dRd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbfH3KYU (ORCPT ); Fri, 30 Aug 2019 06:24:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34684 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbfH3KYU (ORCPT ); Fri, 30 Aug 2019 06:24:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=V0f3Oirj3hv++bmBPXiDjm3i0MZMksovb7Xpg16zinY=; b=eZw94dRd/xLeniBazdw2lJaAL Zx8enQtMkX9MtnMyPKau4A/V7NCic226z5eY3cPbGcPNlfFoZ4UHPHLFqkulwXAdYCB941+lwHbtS 6HnveqKHgAhT+SsIK6BYZJFjdLKNxizIDzMAxGwwsnRnIoPzxunqUNnHtgzsryix9e6QgAeW8jICl kAFLS/ZXR2WMy7xWV7H2d2k104kiA3bAsKLKnY6Crbkc7keLIW0GnLtumOp4jwFUO3QoXGZ4xOlwj OzqY8zXFK0eJ8QtE00mNWF0LQgQU0+CO5sGXMTNYHYdLvb28Nwwj2Jjuv1daF4IWCO2Zj9pvzv9k2 oDBtZ6sMQ==; Received: from [2001:4bb8:180:3f4c:863:2ead:e9d4:da9f] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i3e4q-0003om-32 for linux-xfs@vger.kernel.org; Fri, 30 Aug 2019 10:24:20 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 2/3] xfs: cleanup xfs_fsb_to_db Date: Fri, 30 Aug 2019 12:24:10 +0200 Message-Id: <20190830102411.519-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190830102411.519-1-hch@lst.de> References: <20190830102411.519-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This function isn't a macro anymore, so remove various superflous braces, and explicit cast that is done implicitly due to the return value, use a normal if statement instead of trying to squeeze everything together. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_bmap_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index e12f0ba7f2eb..0910cb75b65d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -39,9 +39,9 @@ xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) { - return (XFS_IS_REALTIME_INODE(ip) ? \ - (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \ - XFS_FSB_TO_DADDR((ip)->i_mount, (fsb))); + if (XFS_IS_REALTIME_INODE(ip)) + return XFS_FSB_TO_BB(ip->i_mount, fsb); + return XFS_FSB_TO_DADDR(ip->i_mount, fsb); } /* From patchwork Fri Aug 30 10:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11123713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 500231399 for ; Fri, 30 Aug 2019 10:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F4FE21721 for ; Fri, 30 Aug 2019 10:24:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EQuYeqHw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbfH3KYX (ORCPT ); Fri, 30 Aug 2019 06:24:23 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34690 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbfH3KYX (ORCPT ); Fri, 30 Aug 2019 06:24:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=d1jGVAacrxxCekQNOC6YwDQy/3hxhm5+fYI7LMrZv68=; b=EQuYeqHweHRP/Ja7W1zoUgK8P 1vlwNRHvwQDWwiX+4XKQZ5w/Cbp8WvwsyNdmvi+D4UKxoRMewcCF6olWSrNMxtZAgkaoJM9YiPaYI KlEMaDa89/l/K6OV5QbohIzp9wXH2AkFeeWUpF+m0Klb9VcR0aRiaGX13vCK2RspvJo8X7M7H1UEQ bFf1qOwtGz0eTcHa/1jAUubBdAWSJVRhN4OUyNwGYER6rrpSChL2SY4CQFZ8S+u4a/LBG6xXX3t8d RAFcoXxykoPe9MUnvQzUNuYFZvNcLSLIcRdjlGoaJe0FvJdt2SEu4oJ8wKGDT8DD6MA7gPTk9Q0xF CDcEx+APA==; Received: from [2001:4bb8:180:3f4c:863:2ead:e9d4:da9f] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i3e4t-0003p6-1m for linux-xfs@vger.kernel.org; Fri, 30 Aug 2019 10:24:23 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 3/3] xfs: remove the unused XFS_ALLOC_USERDATA flag Date: Fri, 30 Aug 2019 12:24:11 +0200 Message-Id: <20190830102411.519-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190830102411.519-1-hch@lst.de> References: <20190830102411.519-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_alloc.h | 7 +++---- fs/xfs/libxfs/xfs_bmap.c | 8 ++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index d6ed5d2c07c2..58fa85cec325 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -81,10 +81,9 @@ typedef struct xfs_alloc_arg { /* * Defines for datatype */ -#define XFS_ALLOC_USERDATA (1 << 0)/* allocation is for user data*/ -#define XFS_ALLOC_INITIAL_USER_DATA (1 << 1)/* special case start of file */ -#define XFS_ALLOC_USERDATA_ZERO (1 << 2)/* zero extent on allocation */ -#define XFS_ALLOC_NOBUSY (1 << 3)/* Busy extents not allowed */ +#define XFS_ALLOC_INITIAL_USER_DATA (1 << 0)/* special case start of file */ +#define XFS_ALLOC_USERDATA_ZERO (1 << 1)/* zero extent on allocation */ +#define XFS_ALLOC_NOBUSY (1 << 2)/* Busy extents not allowed */ static inline bool xfs_alloc_is_userdata(int datatype) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 80b25e21e708..054b4ce30033 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4042,12 +4042,8 @@ xfs_bmapi_allocate( */ if (!(bma->flags & XFS_BMAPI_METADATA)) { bma->datatype = XFS_ALLOC_NOBUSY; - if (whichfork == XFS_DATA_FORK) { - if (bma->offset == 0) - bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; - else - bma->datatype |= XFS_ALLOC_USERDATA; - } + if (whichfork == XFS_DATA_FORK && bma->offset == 0) + bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; if (bma->flags & XFS_BMAPI_ZERO) bma->datatype |= XFS_ALLOC_USERDATA_ZERO; }