From nobody Fri Nov 29 02:52:51 2024 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCB79155C96 for ; Tue, 24 Sep 2024 22:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727217711; cv=none; b=GTKBvF/HRQjwfokWQDtkT4UTawhAKlCSgSzk90/GkN1b1XuWTKQzsJGmDd7g2ngQa+7SOlloeWBPuJm/tBeQXJBuJ+DEZsj/GQr7zboNGdteSxdDjCanei6njyxHBa6Yfuq/XtjswZvYxbJvU+y7oE1RopME/+bVORMWch88Ib8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727217711; c=relaxed/simple; bh=Myyp8NBhaLrbvyMytpCoFFH0i9Qb2P8Vdv0CCqOLW4Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jp0U42AdGyxFxAkx6lhk0Qs3QIpEsDXZiIuHtJ6dpH2hgeZcnnTbzP7sSQGBbqqpg5/uOdz7a60PCgLtNNl8NfRJ0eJmVHrcEZBI+INiwDQ+EssUVB4xgCCMe9/1Kyacc2f4dmATz47l+xCRicE3dYK2JBNCgd46lOde0YQ2SLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=gFnTGghM; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gFnTGghM" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7a99de9beb2so387475185a.3 for ; Tue, 24 Sep 2024 15:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1727217708; x=1727822508; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kMkBt2ndnZsJ25ZrZgkjn9Q08hjBkXqiZSvNSy1oUMg=; b=gFnTGghMaKq/afSXO6GI1uDVFMxy5+5q/YAi1E4Yq14R77/hsRqnWaLnvo3G9zHF1K RlyzYBNpKz41mVWbjlCU3GEgT/BtPAUvg6hWXZu+9frwZX4qtqOZtq0y4Ou9yeZ/t38v sRsi+DEbFCJuDBsi+dtl7XcXhJW070IMtXXkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727217708; x=1727822508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kMkBt2ndnZsJ25ZrZgkjn9Q08hjBkXqiZSvNSy1oUMg=; b=dDISHLZNrBBj2rtzDv7a2PQy0KT0DGMoR0GvoGrKmmR013haTgwRh7QVtRjGc40Lgx 6lvhVlgfSAVkd6JhnQdTx/Z0qMW5UARDSlg4Jrh78ZGY07ayiMBp/Jqc5zFtaP4JLyGL K24amux/GAT9jMemDJ328lHUtoMd2oumyhJjGTRQIOF97TT1souvP32yt/VpMXYPELJL N3vqOD2DISkOhJ2gxHowS9RvaeNZ2bMYFo48Ptm3Z9XTrgaaDr5Yn/skTIN01o53y1d0 3kq7zOheItuWkNXoUH13X/GS5QCUKGWCn0nlv4hhyAfccU7eTipDaXvGdHKa8AnHCvGw pXfA== X-Forwarded-Encrypted: i=1; AJvYcCXtplGVkUjiJtrv21VOcw8/lQMbZfY8U3G2Hk6UMSLRnTSBfGDa3j2kptXiD4/IEeyDaxxGtBm+dR7si5c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5jK3MHv1ms6Qa7gCZvEjZRLKBUuNIt5xpGwopkKD119ljiLqX kFW1jmK7U0yeww8axhoBFhQXssSuQOUxOQLHpRsujhOXFteLUCgGzin7s0PHqA== X-Google-Smtp-Source: AGHT+IF7y2j5ElY99xoXAzTQLdIolfNsFnQAlor+9pe/omCt0w6+bj82DMuXvGASyjMB8LAXhWdU/w== X-Received: by 2002:a05:620a:1786:b0:7a9:d0d2:a5fd with SMTP id af79cd13be357-7ace744d8femr137981085a.49.1727217708492; Tue, 24 Sep 2024 15:41:48 -0700 (PDT) Received: from ubuntu-vm.dhcp.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7acde53d6d3sm114843285a.42.2024.09.24.15.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 15:41:47 -0700 (PDT) From: Kuntal Nayak To: leah.rumancik@gmail.com, jwong@kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Cc: ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vasavi.sirnapalli@broadcom.com, Dave Chinner , "Darrick J . Wong" , Christoph Hellwig , Kuntal Nayak Subject: [PATCH v5.10] xfs: No need for inode number error injection in __xfs_dir3_data_check Date: Tue, 24 Sep 2024 15:39:57 -0700 Message-Id: <20240924223958.347475-2-kuntal.nayak@broadcom.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240924223958.347475-1-kuntal.nayak@broadcom.com> References: <20240924223958.347475-1-kuntal.nayak@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Dave Chinner [ Upstream commit 39d3c0b5968b5421922e2fc939b6d6158df8ac1c ] We call xfs_dir_ino_validate() for every dir entry in a directory when doing validity checking of the directory. It calls xfs_verify_dir_ino() then emits a corruption report if bad or does error injection if good. It is extremely costly: 43.27% [kernel] [k] xfs_dir3_leaf_check_int 10.28% [kernel] [k] __xfs_dir3_data_check 6.61% [kernel] [k] xfs_verify_dir_ino 4.16% [kernel] [k] xfs_errortag_test 4.00% [kernel] [k] memcpy 3.48% [kernel] [k] xfs_dir_ino_validate 7% of the cpu usage in this directory traversal workload is xfs_dir_ino_validate() doing absolutely nothing. We don't need error injection to simulate a bad inode numbers in the directory structure because we can do that by fuzzing the structure on disk. And we don't need a corruption report, because the __xfs_dir3_data_check() will emit one if the inode number is bad. So just call xfs_verify_dir_ino() directly here, and get rid of all this unnecessary overhead: 40.30% [kernel] [k] xfs_dir3_leaf_check_int 10.98% [kernel] [k] __xfs_dir3_data_check 8.10% [kernel] [k] xfs_verify_dir_ino 4.42% [kernel] [k] memcpy 2.22% [kernel] [k] xfs_dir2_data_get_ftype 1.52% [kernel] [k] do_raw_spin_lock Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Signed-off-by: Kuntal Nayak --- fs/xfs/libxfs/xfs_dir2_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c index 375b3edb2..e67fa086f 100644 --- a/fs/xfs/libxfs/xfs_dir2_data.c +++ b/fs/xfs/libxfs/xfs_dir2_data.c @@ -218,7 +218,7 @@ __xfs_dir3_data_check( */ if (dep->namelen =3D=3D 0) return __this_address; - if (xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber))) + if (!xfs_verify_dir_ino(mp, be64_to_cpu(dep->inumber))) return __this_address; if (offset + xfs_dir2_data_entsize(mp, dep->namelen) > end) return __this_address; --=20 2.39.3