Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp394922rdb; Mon, 18 Sep 2023 20:32:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxuGeKWDj6UzgYwkroZcfkIiRX72NHTosq6V0KoY34gpQKIOH20LlJYr9R/DXhTGfdP9ud X-Received: by 2002:a05:6a00:1490:b0:68f:da2a:6370 with SMTP id v16-20020a056a00149000b0068fda2a6370mr11263124pfu.13.1695094371266; Mon, 18 Sep 2023 20:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695094371; cv=none; d=google.com; s=arc-20160816; b=bqaeojt1Zj2aCK4MQMd89pGllmSSYEB5SecwXUWeUyWt1x7ZwBeCtXiZZLg5qSulfN uvhev5QsmMdjbvq7dp2jRIvldjcqfykJixTnWPwZBLjKCh+xY2JgnEuezBfcqdbacTt3 ip3K33DHknqNjWgpMBalt4IASFmdL1hRU+H5iqhzf4Tpt00oc9bOpKEJvyijG+kuFJHQ uZjsY3qoVKK/ITTNyyOND1uXb34ua8biyTTNgOam1acdzGmpkK6SmWsgVvz/ktWh9+Co xHwrQO1KVcCtErQToIMjJQOMIBGtshNqOFJS6fxZcQmMXX3IPpgwggHc0Z5Vs7Yr7lY8 sFWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8RwQOxWtsMsg/1vC3Ov3SEiaC9DLQgxaQY23PDLkYMU=; fh=G98Si/fZwW4Gut8T+kabKctLIWAg909+zJZCyK6Nhj8=; b=qkqRz1XSrei4RNbAQbOk7O+yjY9kenSD7hRMwoNdObY7bfuj+kOk/6I8uuus+oeSUK ftHZAnI85ZHvWOJ+k1q5g3V5aXIwLIASzugUIcSA+m5XDIzBE9BO28F43/fADfIoyk4a X9aAmuccsG1ZeIC7lrN5kwOAy1AkL84Y6821kSsqFSxCnxoRSiY54vfLtDnUiSPkbiV9 XIE+pyoLPrhEz8J69qxqA3ADV2tSL6fCXKDb+qZhvyoDPgf6nKpfp29xj5S1pkpVuAuw tUcSVtvA6DoebowlN4sBpsbjxoRE/y5aV0+8NvcqS01lWxkXBvfbj+c/n0LNIMqrp48x 08wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W5xHjgQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z16-20020a656650000000b005644829012fsi8723379pgv.701.2023.09.18.20.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 20:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W5xHjgQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C6FEE8127272; Mon, 18 Sep 2023 20:32:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjISDbx (ORCPT + 99 others); Mon, 18 Sep 2023 23:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjISDbw (ORCPT ); Mon, 18 Sep 2023 23:31:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3121710E; Mon, 18 Sep 2023 20:31:47 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C131BC433C8; Tue, 19 Sep 2023 03:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695094306; bh=nvqgHfDJCZ+60fWr3N7pdaz5K4+PP37HC3/I0Jy5NuE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W5xHjgQwSJXbB2/DNsyXVpFuF1DSVtFbYjs+fbzR2FJsEIy/QRJRkwaSyKhx0z9sS z860uiDvcuMaDXQXbLxezLnOzMO8SZUmzmr9b0Vnjwh1VocnyIVjRMBENkUWq6RVT/ lf5e7R2/9m/vF2xmTye5OWUBMpYbrJwilioMJ004rK70eUjTgXoVDZnbW8+yKCk4CV GNZwlCdouG0rKTifUm8esD+U/06CIgmBWP2rnTx8gdlPpUD1PIzd08mUVozV25S71J vrna9Gux5+2a0Aw9FfTf/7Ff2brA9QR1m7EQwZ8l5O5dfMiwlJKZhAfSKjmb0VTYzo q4XK1IWZyqFZA== Date: Mon, 18 Sep 2023 20:31:46 -0700 From: "Darrick J. Wong" To: cheng.lin130@zte.com.cn Cc: david@fromorbit.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, jiang.yong5@zte.com.cn, wang.liang82@zte.com.cn, liu.dong3@zte.com.cn Subject: Re: [PATCH v4] xfs: introduce protection for drop nlink Message-ID: <20230919033146.GE348018@frogsfrogsfrogs> References: <202309181450509388561@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202309181450509388561@zte.com.cn> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 20:32:05 -0700 (PDT) On Mon, Sep 18, 2023 at 02:50:50PM +0800, cheng.lin130@zte.com.cn wrote: > From: Cheng Lin > > When abnormal drop_nlink are detected on the inode, > return error, to avoid corruption propagation. > > Signed-off-by: Cheng Lin > --- > fs/xfs/xfs_inode.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c > index 9e62cc500..d16cb62ce 100644 > --- a/fs/xfs/xfs_inode.c > +++ b/fs/xfs/xfs_inode.c > @@ -919,6 +919,14 @@ xfs_droplink( > xfs_trans_t *tp, > xfs_inode_t *ip) > { > + > + if (VFS_I(ip)->i_nlink == 0) { > + xfs_alert(ip->i_mount, > + "%s: Deleting inode %llu with no links.", > + __func__, ip->i_ino); We're not deleting the zero-nlink file, since we return without changing the link count. Also wondering why this doesn't use XFS_IS_CORRUPT? That macro already logs a message about there being problems: struct xfs_mount *mp = ip->i_mount; if (XFS_IS_CORRUPT(mp, VFS_I(ip)->i_nlink == 0)) return -EFSCORRUPTED; --D > + return -EFSCORRUPTED; > + } > + > xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); > > drop_nlink(VFS_I(ip)); > -- > 2.18.1