From patchwork Mon Feb 3 22:40:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13958371 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 24FCE2116E8 for ; Mon, 3 Feb 2025 22:40:24 +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=1738622425; cv=none; b=qvOVAHRkHzEs3A3qqetww2j3uRiS994sKuzKbRGF39kgfSCqK9P7N98ejfIGz0lCZWlF20cH/SfvFv4aFpfTIovBbBKMap+sTanP0/0dd0lxF403uo47gdpxkcAFNt3W5O2OBVUPft0JHegd+Z/vWU4trKU3vEj/m419dNB/hnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738622425; c=relaxed/simple; bh=cCWqeusjE2sVCW2yHkWOxRVFjv73AbPpY32W1CxgDJc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cQOjtslKsD5C8S/Uylh7qY7DzeEa3G2mbxriGxI++cpWFY1PgYAWOuLRiPHC96tJMIt/fJiqGRMPctWRf29X8YDVRNfXGd4Y0AgCQgXTo2stx9ZqON8Lrel0vpIAaJSX2Vx7/pfgGToFg8UyWx23KkqM/oVl6LiuG3gOU8Xc3CA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hldpCeOF; 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="hldpCeOF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B200C4CED2; Mon, 3 Feb 2025 22:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738622424; bh=cCWqeusjE2sVCW2yHkWOxRVFjv73AbPpY32W1CxgDJc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=hldpCeOFYicOHWXc/7N0BxOCJp15c1Y6okEX1DHl1fUODOvfluMmjC112+4RwCMHC F66nVV5Cgjo/KOQTWlC1Iu7ovgVjZ3JVO2cntYD0Zxpgg/MJITGFzsfcW9QexTw2+3 7MjlmcyzpKIKtaOT4s1UL5u0TAJcOIZo70LlmaGuxloApHBjU1kHNdqrmPEfrBm7kj 0JVvqL+Y3C9ZUbwCFqxM13+0yexzTxf4vPDuUxl1c2qtkawBr4FigpR2hPcTGOoxOP eJhEato/sOOSaCStYKUQdVhzDfz/7hOveMvI01/Fyv1okTwvvsxM7HZjOgzFxVyEF1 3GxIei2mCg4CQ== Date: Mon, 03 Feb 2025 14:40:24 -0800 Subject: [PATCH 1/3] mkfs: fix file size setting when interpreting a protofile From: "Darrick J. Wong" To: djwong@kernel.org, aalbersh@kernel.org Cc: hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173862239048.2460098.9569795439422233357.stgit@frogsfrogsfrogs> In-Reply-To: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> References: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong When we're copying a regular file into the filesystem, we should set the size of the new file to the size indicated by the stat data, not the highest offset written, because we now use SEEK_DATA/HOLE to ignore sparse regions. Fixes: 73fb78e5ee8940 ("mkfs: support copying in large or sparse files") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- mkfs/proto.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mkfs/proto.c b/mkfs/proto.c index 4e9e28d4eea1ca..6dd3a2005b15b3 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -313,7 +313,6 @@ writefile( struct xfs_mount *mp = ip->i_mount; struct stat statbuf; off_t data_pos; - off_t eof = 0; int error; /* do not try to read from non-regular files */ @@ -340,8 +339,6 @@ writefile( } writefile_range(ip, fname, fd, data_pos, hole_pos - data_pos); - eof = hole_pos; - data_pos = lseek(fd, hole_pos, SEEK_DATA); } if (data_pos < 0 && errno != ENXIO) @@ -354,7 +351,7 @@ writefile( fail(_("error creating isize transaction"), error); libxfs_trans_ijoin(tp, ip, 0); - ip->i_disk_size = eof; + ip->i_disk_size = statbuf.st_size; libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); error = -libxfs_trans_commit(tp); if (error) From patchwork Mon Feb 3 22:40:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13958372 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 DEA152116E6 for ; Mon, 3 Feb 2025 22:40:40 +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=1738622441; cv=none; b=nKwk+FYUTNHKHBoLQeve/j0eg/gtiBEREsJz9BxhQwMD5DUT+TxZY2QK+F5xXuSAFQE/6bBm92MV7CNPdfYB5s7aeBvPj+QHFvHDrixqmSzT71iOWhmYBoXQlImdJ0O4HpYmTF2msrhe6/DXsuWJrCWeDCWft5KEQW7vp5mmP3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738622441; c=relaxed/simple; bh=19H71VHcjwdMutC2ZYwxdIceJxqIwhZm15tJcWligPA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jsqReB3tql9HWybH25pciH7HaH/TbMsb8kkrp8QGUv5IStXI1zV7E54Vc+GipughPHyY6R6kHu2WfqvmdzH3HMyZNTgWyNpNfsahttRAXKuWBBoQvsZyDmp5ksJDwAhk5a822VvI6bar/Nq4qUi813wFpkaJz+MUEUUmyqbGF4M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b3cVbOl4; 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="b3cVbOl4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46363C4CED2; Mon, 3 Feb 2025 22:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738622440; bh=19H71VHcjwdMutC2ZYwxdIceJxqIwhZm15tJcWligPA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=b3cVbOl4TIU8qtC7lkL6KWpR25Rmb981Nx5LvfS3Tf0Wc5NrmiBgBqvCnBy5sJ97B FYwABcLcWmsiE3bw36As44yPZqwCyPbht+L0KX0Mb5+NstjmVDR/3vsYeXnaWbm/JI NJnE5HLKhpKmA+pgjKqKv+r5b1v8UsZ1Lfq3jHp+AhQ5GZtE/esQlLfpdNNY+tiNo6 hFCRc1xoZsa9FkWBRuEUU/o+qixaJB08Vu0rCQLz9T2WO3P9WzxHS/9u+FNBS8vwEl QncmMaH3FqVy/ZJ2+6xSykfzQc5Ktaa55+QYrQmqfE3QBheCnCT8rOJ6GeI2+r35sE +h5uvItpnPU1A== Date: Mon, 03 Feb 2025 14:40:39 -0800 Subject: [PATCH 2/3] xfs_protofile: fix mode formatting error From: "Darrick J. Wong" To: djwong@kernel.org, aalbersh@kernel.org Cc: hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173862239063.2460098.16773056715229696499.stgit@frogsfrogsfrogs> In-Reply-To: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> References: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong The protofile parser expects the mode to be specified with three octal digits. Unfortunately, the generator doesn't get that right if the mode doesn't have any of bits 8-11 (aka no owner access privileges) set. Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- mkfs/xfs_protofile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in index 9aee4336888523..356d3d80b32521 100644 --- a/mkfs/xfs_protofile.in +++ b/mkfs/xfs_protofile.in @@ -45,7 +45,7 @@ def stat_to_str(statbuf): perms = stat.S_IMODE(statbuf.st_mode) - return '%s%s%s%o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \ + return '%s%s%s%03o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \ statbuf.st_gid) def stat_to_extra(statbuf, fullpath): From patchwork Mon Feb 3 22:40:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13958373 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 6CA40211464 for ; Mon, 3 Feb 2025 22:40:56 +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=1738622456; cv=none; b=myfeME8vdToKBR/r+Xx9H1w5ntsuYJvw1yL0LKFiMWaukZU1azPL25jzLS/V62EUpbivW/iAsxEaz+ijE50+E32dc1T8m2y2eHQhGae5XuPyHCeRaJ3lSM4xgiJOEUYkE7WVNLS0J0txlp46C2oHy6t9LX7F2r1IVy5T4rOXNLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738622456; c=relaxed/simple; bh=At4/aYvvzlno9xVoygEuLtzkOwdigoDfydVvvfdjOWU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sx5mJmMet6Mlgse8NLl4yZshUgPqPxogI4wqj3hpxmDDEo0bbzRrSojFzYPqECqYG9sbxSxz69qZrDxvx42EXgJ9ZaqY8NVkv1l+vMi71dfux4cBPsHz/0Iu2HtBU8qPBMbDeC6rw5sG4h/Y+Mi7MVGjYdTc6LjCOE0X9KNkBAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=em/TrR3j; 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="em/TrR3j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5FE5C4CED2; Mon, 3 Feb 2025 22:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738622455; bh=At4/aYvvzlno9xVoygEuLtzkOwdigoDfydVvvfdjOWU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=em/TrR3jdbHx1tzCOD3b2c/hqKWZjX1QLikhHdu/ll0KwS1DdvKrsPlggZd/br8iV vkg+uqUMxPCmmv0LiHQyPZ9TJ9foCE0/LfP9M7L9iP8A/bi/nhHzsfn7/2biNtuFfP YpAGh4LIsUkNE9o0wIJzJ8L2pfU5eHwJ7uwU6tXCbV7H2POF1eg3EXSjuHvibUbXby MFjq5G92LmRtn8/aB2z/4oAdtGCpxz9dPfGMrAbyAuqSMTJqKfQM9UwTVfIb6emqU4 JJYogonLunc53Hvcz9ZS5z/KK3cK325UbcwMBDMZo/k6dEWSpkyDMap5XENHqJg2e0 t1jIU8d7UYaLA== Date: Mon, 03 Feb 2025 14:40:55 -0800 Subject: [PATCH 3/3] xfs_protofile: fix device number encoding From: "Darrick J. Wong" To: djwong@kernel.org, aalbersh@kernel.org Cc: hch@lst.de, linux-xfs@vger.kernel.org Message-ID: <173862239078.2460098.2761986507883680426.stgit@frogsfrogsfrogs> In-Reply-To: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> References: <173862239029.2460098.9677559939449638172.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Actually crack major/minor device numbers from the stat results that we get when we encounter a character/block device file. Fixes: 6aace700b7b82d ("mkfs: add a utility to generate protofiles") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- mkfs/xfs_protofile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in index 356d3d80b32521..e83c39f5325846 100644 --- a/mkfs/xfs_protofile.in +++ b/mkfs/xfs_protofile.in @@ -54,7 +54,7 @@ def stat_to_extra(statbuf, fullpath): if stat.S_ISREG(statbuf.st_mode): return ' %s' % fullpath elif stat.S_ISCHR(statbuf.st_mode) or stat.S_ISBLK(statbuf.st_mode): - return ' %d %d' % (statbuf.st_rdev, statbuf.st_rdev) + return ' %d %d' % (os.major(statbuf.st_rdev), os.minor(statbuf.st_rdev)) elif stat.S_ISLNK(statbuf.st_mode): return ' %s' % os.readlink(fullpath) return ''