From patchwork Wed Apr 17 21:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13633937 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 93B4447F62 for ; Wed, 17 Apr 2024 21:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390003; cv=none; b=hZ+0xiLDNVWagD2zRCiMC6zmknzwBz8V6SrxYiUfdTsvZv/Ar4Ojfm7s0a864YN4uyWk6Bad6cUYX8MkhWVYf3T6FQYbiI1fl+9r5xtDrhR6BXT6YzM7bLKs5NzdDezQH2UaKtvKvHkw/9kyt282Q/dRY2xOw7eufky78G2oVj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390003; c=relaxed/simple; bh=VDttbx9llvoRS+pAx4UZyKJs+hNe4V040VNY2SBVvF0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PFSxAWmlI08Nwl58+ekji/ObqkRyWEvL2CCrpYtFBo55YiQefaXq+Zxs/Nj3rB/VuTcSD/wKYHdAhlTR1tpsuSwiXdTT+YI0jOr0pe2H1bH0D5xJJ3Dgx/GWEe+RVD87yLaRPq8mCV3YnwVvXv7I8tfMWxWEXjzCDuaGC9mI4FI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cOyaiQel; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cOyaiQel" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2502BC072AA; Wed, 17 Apr 2024 21:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713390003; bh=VDttbx9llvoRS+pAx4UZyKJs+hNe4V040VNY2SBVvF0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cOyaiQel8XDhVR2i9+W+vhoG9fMfzBXmrSl9AkJKWH90EHsa1sF8HFyBIN6NdCgrB L5BvSZJv3FQPEGWYzhfw68qYL2RafJkL2ZJaW2PgmheVXSlvXSt20HxGilsiBvnvPz PAbMeavgJyk5UhADrg6uL1jjbrNpe+wCWYWBhT29uOvmO58yHdwvOb0nz8XV3J0Hv0 qLTtazc3vq8aRqkkhqG6el/2nqzsuokwHKCg86kb7fF5oExwIBLqmkk0UR9f8EhduD hduoOh+LPGKVXPVMwo8sQJJ+R/huQ69USwwdoxWIJjk5nnA1FULW5S/nuoUpc6MKxK TRQJZkzbT84/g== Date: Wed, 17 Apr 2024 14:40:02 -0700 Subject: [PATCH 1/5] xfs_repair: double-check with shortform attr verifiers From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , Bill O'Donnell , linux-xfs@vger.kernel.org Message-ID: <171338843994.1855783.13822938144858807764.stgit@frogsfrogsfrogs> In-Reply-To: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> References: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Call the shortform attr structure verifier as the last thing we do in process_shortform_attr to make sure that we don't leave any latent errors for the kernel to stumble over. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Bill O'Donnell --- repair/attr_repair.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 01e4afb90..f117f9aef 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -212,6 +212,7 @@ process_shortform_attr( { struct xfs_attr_sf_hdr *hdr = XFS_DFORK_APTR(dip); struct xfs_attr_sf_entry *currententry, *nextentry, *tempentry; + xfs_failaddr_t fa; int i, junkit; int currentsize, remainingspace; @@ -373,6 +374,22 @@ process_shortform_attr( } } + fa = libxfs_attr_shortform_verify(hdr, be16_to_cpu(hdr->totsize)); + if (fa) { + if (no_modify) { + do_warn( + _("inode %" PRIu64 " shortform attr verifier failure, would have cleared attrs\n"), + ino); + } else { + do_warn( + _("inode %" PRIu64 " shortform attr verifier failure, cleared attrs\n"), + ino); + hdr->count = 0; + hdr->totsize = cpu_to_be16(sizeof(struct xfs_attr_sf_hdr)); + *repair = 1; + } + } + return(*repair); } From patchwork Wed Apr 17 21:40:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13633938 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 343EE2BAE2 for ; Wed, 17 Apr 2024 21:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390019; cv=none; b=tF0B0VNn1aIyHdqcI7CpCqj7JYWU2sXOw7SloyY9BRtoBOQQtddBQbGRdEv3qi6hvZYz/BTjz3KVpWg6pzODq8231b5lYFB5m+yq/56boP+oIpohjrdSpMGEnmBAO/iB0wde7WmUJ6VUvaf7BZ31OS98sZc/Xc2SlTKRlaJbSgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390019; c=relaxed/simple; bh=nKINfQjIBvYvXJ9KasYywQZ0dEsCjqlEK21IHApGVSA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=COAZU4s6gj/5qBkkwK9PFsi576s7Y1MyUa9oZSfGfLvma38UwwlWP0R23YmCfUbGYkIZEIxVxanesCvOjNcYjo0C7rpq/Ef0c8bkEjPBX7WlGMfJ/tQV6aa2PdQYjfAU5ugn2sdtu/b1RaqS6VfZgq64/ZP0DK2B7ohJdn2DHqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CNNyutnC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CNNyutnC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C262AC072AA; Wed, 17 Apr 2024 21:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713390018; bh=nKINfQjIBvYvXJ9KasYywQZ0dEsCjqlEK21IHApGVSA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=CNNyutnCcBqTSa8JZeQWQUXmYR+PBRD8J94hwurbNEcnspucruzvBxqd+O58ssHzF IZRKNOjzbx21D1BivHi6I7fjvyGmH7cV4Tt6jhLYCjMpyIL+wiGA/Tp/INwA2AKkka LAAN7maVjA0oF6pz72ytMaCwKXBfQXrfQ9v/tnIB3jnM2+7q8bGCrgntXaLSIvY9ez TpzkNg/FQa/UZYDfZW3PDCYqwVeCZTp2VlMsApeR26muafl2KHZ9HGwGqKZzotV8EZ z9BObPNr5Z5FRxOdCPnu4SZI9/4xRAojL8HspUWnVIZBYoDU/Hm3+hQvXuYt5KVJJO Mfag+XGuOEO2A== Date: Wed, 17 Apr 2024 14:40:18 -0700 Subject: [PATCH 2/5] xfs_db: improve number extraction in getbitval From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <171338844009.1855783.3559063058372490721.stgit@frogsfrogsfrogs> In-Reply-To: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> References: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong For some reason, getbitval insists upon collecting a u64 from a pointer bit by bit if it's not aligned to a 16-byte boundary. If not, then it resorts to scraping bits individually. I don't know of any platform where we require 16-byte alignment for a 8-byte access, or why we'd care now that we have things like get_unaligned_beXX. Rework this function to detect either naturally aligned accesses and use the regular beXX_to_cpu functions; or byte-aligned accesses and use the get_unaligned_beXX functions. Only fall back to the bit scraping algorithm for the really weird cases. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- db/bit.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/db/bit.c b/db/bit.c index c9bfd2eb0..1b9ca054f 100644 --- a/db/bit.c +++ b/db/bit.c @@ -55,39 +55,34 @@ getbitval( char *p; int64_t rval; int signext; - int z1, z2, z3, z4; ASSERT(nbits<=64); p = (char *)obj + byteize(bitoff); bit = bitoffs(bitoff); signext = (flags & BVSIGNED) != 0; - z4 = ((intptr_t)p & 0xf) == 0 && bit == 0; - if (nbits == 64 && z4) - return be64_to_cpu(*(__be64 *)p); - z3 = ((intptr_t)p & 0x7) == 0 && bit == 0; - if (nbits == 32 && z3) { + + if (bit != 0) + goto scrape_bits; + + switch (nbits) { + case 64: + return get_unaligned_be64(p); + case 32: if (signext) - return (__s32)be32_to_cpu(*(__be32 *)p); - else - return (__u32)be32_to_cpu(*(__be32 *)p); - } - z2 = ((intptr_t)p & 0x3) == 0 && bit == 0; - if (nbits == 16 && z2) { + return (__s32)get_unaligned_be32(p); + return (__u32)get_unaligned_be32(p); + case 16: if (signext) - return (__s16)be16_to_cpu(*(__be16 *)p); - else - return (__u16)be16_to_cpu(*(__be16 *)p); - } - z1 = ((intptr_t)p & 0x1) == 0 && bit == 0; - if (nbits == 8 && z1) { + return (__s16)get_unaligned_be16(p); + return (__u16)get_unaligned_be16(p); + case 8: if (signext) return *(__s8 *)p; - else - return *(__u8 *)p; + return *(__u8 *)p; } - +scrape_bits: for (i = 0, rval = 0LL; i < nbits; i++) { if (getbit_l(p, bit + i)) { /* If the last bit is on and we care about sign From patchwork Wed Apr 17 21:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13633939 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AE821171A1 for ; Wed, 17 Apr 2024 21:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390034; cv=none; b=cphUYzKr82sFOtrLj6qqoXbD5TET2tfAUaGZjbm0fII92KM35TxYhaQqOUuxyyrBoWvwwl4l/zg5WWCBYLPsYyUxryPuoE6e/PP/fxDTyOYbbMxycvolwzMNBAtRJEw51fdCDUbB4KZ0to37aRmAekw8eNxieeqq/HGN1Ye6bv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390034; c=relaxed/simple; bh=ZyKGosPztRbhz3cKB2Ce99cbEzgVsubIDVJF/c1KzlU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V9sBXkG3MkCieERGoaHOBOwRnrqubXmJOsnKjYP1Jg/XoynoG56Xo/4choFLNbdp2goUaoFNH9sbF56sbTXEkzX6F5euJnYfznHC57gF75h2cDxhasl+Wx8/3JAS1uac9KqPxgGvvBXpEqiyOIKZ6xkGXT7G8eILUucvJMuQv+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=heAdl/9k; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="heAdl/9k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88926C072AA; Wed, 17 Apr 2024 21:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713390034; bh=ZyKGosPztRbhz3cKB2Ce99cbEzgVsubIDVJF/c1KzlU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=heAdl/9kKX6b7Qzd+muOV1vvXUTnxJ/zmZQEPvhN0Hh84qUThaLwOi1EXmCnXzhFS 0hE7IxWZD0PJWo9yA9e9I2NwJFMu2qRg3Iz341mjfNVdeGzYgJz6W5RgwbjSqG47z4 8Ayl09wleXjq07B9yQWegD22SyYLICsYl+/A3NZQNzZnBozLCzbWHic1AytP/shC8W 5WmiBA3rxtsbWS+fTTk5buj7fdCTfzzGS/u2s9qxt+RTI5UQen2tlRQSdgplXNOCUo d2tWxJQE0cD8L8t71ffBLq7uGYg/Macw+r13o4W+NLfdmnwbjpwhMC002iPNViC2Jp 3PyFAF5PGT5uQ== Date: Wed, 17 Apr 2024 14:40:33 -0700 Subject: [PATCH 3/5] xfs_scrub: fix threadcount estimates for phase 6 From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <171338844023.1855783.12171367969251823508.stgit@frogsfrogsfrogs> In-Reply-To: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> References: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If a filesystem has a realtime device or an external log device, the media scan can start up a separate readverify controller (and workqueue) to handle that. Each of those controllers can call progress_add, so we need to bump up nr_threads so that the progress reports controller knows to make its ptvar big enough to handle all these threads. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase6.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scrub/phase6.c b/scrub/phase6.c index 99a32bc79..393d9eaa8 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -743,7 +743,17 @@ phase6_estimate( *items = cvt_off_fsb_to_b(&ctx->mnt, (d_blocks - d_bfree) + (r_blocks - r_bfree)); + + /* + * Each read-verify pool starts a thread pool, and each worker thread + * can contribute to the progress counter. Hence we need to set + * nr_threads appropriately to handle that many threads. + */ *nr_threads = disk_heads(ctx->datadev); + if (ctx->rtdev) + *nr_threads += disk_heads(ctx->rtdev); + if (ctx->logdev) + *nr_threads += disk_heads(ctx->logdev); *rshift = 20; return 0; } From patchwork Wed Apr 17 21:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13633941 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5D533171A1 for ; Wed, 17 Apr 2024 21:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390050; cv=none; b=ERdGuc3dnl1e+8U55LOKiUW/+YFdHXa6oCHFS4AJKeu42BKySuCNtC4KXnajy97znj2ejR0ujbfJdUAD98O6RYglnoyRa5hJzCtmrf2ALwnzAtWHbmVbLzrhwblogEtl1G7LvAVw6ACzj1AT08Gp3W86k724john5BsvbA5+20Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390050; c=relaxed/simple; bh=CeUo0ddAFaE14CdVI6ASY2CA5kUhGQae+h7QbQp8Rmw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X3FP9oM9dg3otIydAmU5AvENk5NWqjcnUtm/GfaGxrqXErDT+6JvAk8H9Oill6y2LdqaoImbvTiuU+gTjGzLJywxCOzSUDKysSkblj0SuC2qnDF8vFbi6V2lNKJV9/C9MXW1cgxigMxuvCix9QukFjByYsYsjsoXjf09fvdLR+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cj8Q1Ijw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cj8Q1Ijw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39E6AC072AA; Wed, 17 Apr 2024 21:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713390050; bh=CeUo0ddAFaE14CdVI6ASY2CA5kUhGQae+h7QbQp8Rmw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cj8Q1IjwWV7Tzhu6j+5q7pgyLE5Y70Uh1eFjmIV84Qs0WN4bmuphml5rHMmq3TfG2 6RuL4j7XPvvLBQRG647BPfhRtdUbAdVnOK10sQH2KOIlfefK9mYQovYIDjzLEzhqkm yIEW8pBXiQkNxnVupXxQlHKICrtv7DMoHBJZLJrpFew47ZAG2dg5pm3P4V1xVOycmw l4t0zOm+FfhZrKJ5WH9pNS6OVXslLux4tTuxVNnSw/sT6fISX+hB217sl4r1gcPvZQ Qczap8VeVwtTqCAf29ss8/I2opNJ3z+ibGAHdAs2lSzkoEfmnkfu0z6VN7I+3kOMIW 5nrNI2p2OTj/Q== Date: Wed, 17 Apr 2024 14:40:49 -0700 Subject: [PATCH 4/5] xfs_scrub: don't fail while reporting media scan errors From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <171338844038.1855783.13633655559187788087.stgit@frogsfrogsfrogs> In-Reply-To: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> References: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If we can't open a file to report that it has media errors, just log that fact and move on. In this case we want to keep going with phase 6 so we report as many errors as possible. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- scrub/phase6.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scrub/phase6.c b/scrub/phase6.c index 393d9eaa8..193d3b4e9 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -21,6 +21,7 @@ #include "read_verify.h" #include "spacemap.h" #include "vfs.h" +#include "common.h" /* * Phase 6: Verify data file integrity. @@ -291,13 +292,14 @@ report_inode_loss( /* Try to open the inode. */ fd = scrub_open_handle(handle); if (fd < 0) { - error = errno; - if (error == ESTALE) - return error; + /* Handle is stale, try again. */ + if (errno == ESTALE) + return ESTALE; - str_info(ctx, descr, -_("Disappeared during read error reporting.")); - return error; + str_error(ctx, descr, + _("Could not open to report read errors: %s."), + strerror(errno)); + return 0; } /* Go find the badness. */ @@ -353,10 +355,18 @@ report_dirent_loss( fd = openat(dir_fd, dirent->d_name, O_RDONLY | O_NOATIME | O_NOFOLLOW | O_NOCTTY); if (fd < 0) { + char descr[PATH_MAX + 1]; + if (errno == ENOENT) return 0; - str_errno(ctx, path); - return errno; + + snprintf(descr, PATH_MAX, "%s/%s", path, dirent->d_name); + descr[PATH_MAX] = 0; + + str_error(ctx, descr, + _("Could not open to report read errors: %s."), + strerror(errno)); + return 0; } /* Go find the badness. */ From patchwork Wed Apr 17 21:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13633942 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 03F66171A1 for ; Wed, 17 Apr 2024 21:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390066; cv=none; b=VQWBAvWGPmlC2ojDSe5cSjVT5jN23/1ycw4kBjODcsHEoMylfBfbMxgq/I+3g+f4b2wA5ctQnUC1f+FFBsmo1Ls8ufMWYuC+jkWAksFNrlHipgUuPDRrlqY1/VFsH1HDZ4T5ltTt0PUBxaS6+3Ij5YooTaxROZM0CS6DNn0NmjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713390066; c=relaxed/simple; bh=N0pRjMUyIA/8gxE9ykqJDfyfZTz8akEPJ2W1Ve6awDo=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=psyzKSkMNSTh6lhOBc6u5ULUY9ksy1GGF2A5i0aQEvPAPd5ZkgkGJkaVpBWOD7FN/oM2DASuZvzmiElezRuIibdQp5lUvdQ6kNy12P24AI0U7PAfM9Ifg0aF2OKl0/FJTvrMmy3TTLhbtojpvbQx4BBJCqOd2M3gQG+Dz5R/p3E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JmeY5aII; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JmeY5aII" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB8D5C072AA; Wed, 17 Apr 2024 21:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713390065; bh=N0pRjMUyIA/8gxE9ykqJDfyfZTz8akEPJ2W1Ve6awDo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=JmeY5aIIOhUZ4nSj/vglOfI9n+gzfKAAlIB5oOs8LU1no4Zi1nJlHZK7G8dTvdIji n3j6VdCoYh3XtoNlNmyrmepAJ1Yij1lGrdBRvIHiQCrm4IjX7ZVjB31ECMb7Z1nenK ghxiPghGf1AO1+KoSbufjQwreikqdz4oPj7+OFeROXQOD77Q9Zz1gBHmpBd3WMsLHN 2EMdE812/qalw3xfe954DifCxzKQQeFEzz58CrIi4lEyLvxBDUmIzwuD4MELHOrkM1 5vrYz52pRZnFXl7wBAxPRbE+sRmoCUdL+SXBmXDo7YFUEyiy8P3B1xPqqm6FSwcn7G KpfFxMqELQTSA== Date: Wed, 17 Apr 2024 14:41:05 -0700 Subject: [PATCH 5/5] xfs_io: add linux madvise advice codes From: "Darrick J. Wong" To: cem@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org Message-ID: <171338844053.1855783.9752629961635955337.stgit@frogsfrogsfrogs> In-Reply-To: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> References: <171338843974.1855783.10770063375037351343.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Add all the Linux-specific madvise codes. We're going to need MADV_POPULATE_READ for a regression test. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- io/madvise.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/io/madvise.c b/io/madvise.c index 6e9c5b121..ede233955 100644 --- a/io/madvise.c +++ b/io/madvise.c @@ -9,6 +9,7 @@ #include #include "init.h" #include "io.h" +#include static cmdinfo_t madvise_cmd; @@ -26,6 +27,31 @@ madvise_help(void) " -r -- expect random page references (POSIX_MADV_RANDOM)\n" " -s -- expect sequential page references (POSIX_MADV_SEQUENTIAL)\n" " -w -- will need these pages (POSIX_MADV_WILLNEED) [*]\n" +"\n" +"The following Linux-specific advise values are available:\n" +#ifdef MADV_COLLAPSE +" -c -- try to collapse range into transparent hugepages (MADV_COLLAPSE)\n" +#endif +#ifdef MADV_COLD +" -D -- deactivate the range (MADV_COLD)\n" +#endif +" -f -- free the range (MADV_FREE)\n" +" -h -- disable transparent hugepages (MADV_NOHUGEPAGE)\n" +" -H -- enable transparent hugepages (MADV_HUGEPAGE)\n" +" -m -- mark the range mergeable (MADV_MERGEABLE)\n" +" -M -- mark the range unmergeable (MADV_UNMERGEABLE)\n" +" -o -- mark the range offline (MADV_SOFT_OFFLINE)\n" +" -p -- punch a hole in the file (MADV_REMOVE)\n" +" -P -- poison the page cache (MADV_HWPOISON)\n" +#ifdef MADV_POPULATE_READ +" -R -- prefault in the range for read (MADV_POPULATE_READ)\n" +#endif +#ifdef MADV_POPULATE_WRITE +" -W -- prefault in the range for write (MADV_POPULATE_WRITE)\n" +#endif +#ifdef MADV_PAGEOUT +" -X -- reclaim the range (MADV_PAGEOUT)\n" +#endif " Notes:\n" " NORMAL sets the default readahead setting on the file.\n" " RANDOM sets the readahead setting on the file to zero.\n" @@ -45,20 +71,69 @@ madvise_f( int advise = MADV_NORMAL, c; size_t blocksize, sectsize; - while ((c = getopt(argc, argv, "drsw")) != EOF) { + while ((c = getopt(argc, argv, "cdDfhHmMopPrRswWX")) != EOF) { switch (c) { +#ifdef MADV_COLLAPSE + case 'c': /* collapse to thp */ + advise = MADV_COLLAPSE; + break; +#endif case 'd': /* Don't need these pages */ advise = MADV_DONTNEED; break; +#ifdef MADV_COLD + case 'D': /* make more likely to be reclaimed */ + advise = MADV_COLD; + break; +#endif + case 'f': /* page range out of memory */ + advise = MADV_FREE; + break; + case 'h': /* enable thp memory */ + advise = MADV_HUGEPAGE; + break; + case 'H': /* disable thp memory */ + advise = MADV_NOHUGEPAGE; + break; + case 'm': /* enable merging */ + advise = MADV_MERGEABLE; + break; + case 'M': /* disable merging */ + advise = MADV_UNMERGEABLE; + break; + case 'o': /* offline */ + advise = MADV_SOFT_OFFLINE; + break; + case 'p': /* punch hole */ + advise = MADV_REMOVE; + break; + case 'P': /* poison */ + advise = MADV_HWPOISON; + break; case 'r': /* Expect random page references */ advise = MADV_RANDOM; break; +#ifdef MADV_POPULATE_READ + case 'R': /* fault in pages for read */ + advise = MADV_POPULATE_READ; + break; +#endif case 's': /* Expect sequential page references */ advise = MADV_SEQUENTIAL; break; case 'w': /* Will need these pages */ advise = MADV_WILLNEED; break; +#ifdef MADV_POPULATE_WRITE + case 'W': /* fault in pages for write */ + advise = MADV_POPULATE_WRITE; + break; +#endif +#ifdef MADV_PAGEOUT + case 'X': /* reclaim memory */ + advise = MADV_PAGEOUT; + break; +#endif default: exitcode = 1; return command_usage(&madvise_cmd);