All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 03/12] fs/adfs: add helper to get filesystem size
Date: Tue, 04 Jun 2019 14:49:36 +0100	[thread overview]
Message-ID: <E1hY9om-00084V-8X@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20190604111943.GA15281@rmk-PC.armlinux.org.uk>

Add a helper to get the filesystem size from the disc record and
eliminate the "s_size" member of the adfs superblock structure.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 fs/adfs/adfs.h  |  7 ++++++-
 fs/adfs/super.c | 17 +++--------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 5a72a0ea03bd..ab13b5dd34a3 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -58,7 +58,6 @@ struct adfs_sb_info {
 	__u32		s_ids_per_zone;	/* max. no ids in one zone */
 	__u32		s_idlen;	/* length of ID in map */
 	__u32		s_map_size;	/* sector size of a map	*/
-	unsigned long	s_size;		/* total size (in blocks) of this fs */
 	signed int	s_map2blk;	/* shift left by this for map->sector*/
 	unsigned int	s_log2sharesize;/* log2 share size */
 	__le32		s_version;	/* disc format version */
@@ -201,3 +200,9 @@ struct adfs_discrecord *adfs_map_discrecord(struct adfs_discmap *dm)
 {
 	return (void *)(dm[0].dm_bh->b_data + 4);
 }
+
+static inline u64 adfs_disc_size(const struct adfs_discrecord *dr)
+{
+	return (u64)le32_to_cpu(dr->disc_size_high) << 32 |
+		    le32_to_cpu(dr->disc_size);
+}
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 75000165f4d1..90b9cbcdb4db 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -220,12 +220,13 @@ static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
 	struct super_block *sb = dentry->d_sb;
 	struct adfs_sb_info *sbi = ADFS_SB(sb);
+	struct adfs_discrecord *dr = adfs_map_discrecord(sbi->s_map);
 	u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
 
 	buf->f_type    = ADFS_SUPER_MAGIC;
 	buf->f_namelen = sbi->s_namelen;
 	buf->f_bsize   = sb->s_blocksize;
-	buf->f_blocks  = sbi->s_size;
+	buf->f_blocks  = adfs_disc_size(dr) >> sb->s_blocksize_bits;
 	buf->f_files   = sbi->s_ids_per_zone * sbi->s_map_size;
 	buf->f_bavail  =
 	buf->f_bfree   = adfs_map_free(sb);
@@ -335,8 +336,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
 	i = zone - 1;
 	dm[0].dm_startblk = 0;
 	dm[0].dm_startbit = ADFS_DR_SIZE_BITS;
-	dm[i].dm_endbit   = (le32_to_cpu(dr->disc_size_high) << (32 - dr->log2bpmb)) +
-			    (le32_to_cpu(dr->disc_size) >> dr->log2bpmb) +
+	dm[i].dm_endbit   = (adfs_disc_size(dr) >> dr->log2bpmb) +
 			    (ADFS_DR_SIZE_BITS - i * zone_size);
 
 	if (adfs_checkmap(sb, dm))
@@ -352,16 +352,6 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
 	return ERR_PTR(-EIO);
 }
 
-static inline unsigned long adfs_discsize(struct adfs_discrecord *dr, int block_bits)
-{
-	unsigned long discsize;
-
-	discsize  = le32_to_cpu(dr->disc_size_high) << (32 - block_bits);
-	discsize |= le32_to_cpu(dr->disc_size) >> block_bits;
-
-	return discsize;
-}
-
 static int adfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct adfs_discrecord *dr;
@@ -451,7 +441,6 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
 	asb->s_idlen		= dr->idlen;
 	asb->s_map_size		= dr->nzones | (dr->nzones_high << 8);
 	asb->s_map2blk		= dr->log2bpmb - dr->log2secsize;
-	asb->s_size    		= adfs_discsize(dr, sb->s_blocksize_bits);
 	asb->s_version 		= dr->format_version;
 	asb->s_log2sharesize	= dr->log2sharesize;
 
-- 
2.7.4


  parent reply	other threads:[~2019-06-04 13:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190604111943.GA15281@rmk-PC.armlinux.org.uk>
2019-06-04 13:49 ` [PATCH 01/12] fs/adfs: correct disc record structure Russell King
2019-06-04 13:49 ` [PATCH 02/12] fs/adfs: add helper to get discrecord from map Russell King
2019-06-04 13:49 ` Russell King [this message]
2019-06-04 13:49 ` [PATCH 04/12] fs/adfs: use format_version from disc_record Russell King
2019-06-04 13:49 ` [PATCH 05/12] fs/adfs: use %pV for error messages Russell King
2019-06-04 13:49 ` [PATCH 06/12] fs/adfs: clean up error message printing Russell King
2019-06-04 13:49 ` [PATCH 07/12] fs/adfs: clean up indirect disc addresses and fragment IDs Russell King
2019-06-04 13:50 ` [PATCH 08/12] fs/adfs: super: correct superblock flags Russell King
2019-06-04 13:50 ` [PATCH 09/12] fs/adfs: super: safely update options on remount Russell King
2019-06-04 13:50 ` [PATCH 10/12] fs/adfs: super: fix use-after-free bug Russell King
2019-06-04 13:50 ` [PATCH 11/12] fs/adfs: super: limit idlen according to directory type Russell King
2019-06-04 13:50 ` [PATCH 12/12] fs/adfs: add time stamp and file type helpers Russell King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1hY9om-00084V-8X@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.