From: Jan Kara <jack@suse.cz>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Jan Kara <jack@suse.cz>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] udf: Fix free space reporting for metadata and virtual partitions
Date: Thu, 9 Jan 2020 13:44:05 +0100 [thread overview]
Message-ID: <20200109124405.GE22232@quack2.suse.cz> (raw)
In-Reply-To: <20200108223240.gi5g2jza3rxuzk6z@pali>
On Wed 08-01-20 23:32:40, Pali Rohár wrote:
> On Wednesday 08 January 2020 13:19:19 Jan Kara wrote:
> > Free space on filesystems with metadata or virtual partition maps
> > currently gets misreported. This is because these partitions are just
> > remapped onto underlying real partitions from which keep track of free
> > blocks. Take this remapping into account when counting free blocks as
> > well.
> >
> > Reported-by: Pali Rohár <pali.rohar@gmail.com>
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/udf/super.c | 19 ++++++++++++++-----
> > 1 file changed, 14 insertions(+), 5 deletions(-)
> >
> > I plan to take this patch to my tree.
> >
> > diff --git a/fs/udf/super.c b/fs/udf/super.c
> > index 8c28e93e9b73..b89e420a4b85 100644
> > --- a/fs/udf/super.c
> > +++ b/fs/udf/super.c
> > @@ -2492,17 +2492,26 @@ static unsigned int udf_count_free_table(struct super_block *sb,
> > static unsigned int udf_count_free(struct super_block *sb)
> > {
> > unsigned int accum = 0;
> > - struct udf_sb_info *sbi;
> > + struct udf_sb_info *sbi = UDF_SB(sb);
> > struct udf_part_map *map;
> > + unsigned int part = sbi->s_partition;
> > + int ptype = sbi->s_partmaps[part].s_partition_type;
> > +
> > + if (ptype == UDF_METADATA_MAP25) {
> > + part = sbi->s_partmaps[part].s_type_specific.s_metadata.
> > + s_phys_partition_ref;
> > + } else if (ptype == UDF_VIRTUAL_MAP15 || ptype == UDF_VIRTUAL_MAP20) {
> > + part = UDF_I(sbi->s_vat_inode)->i_location.
> > + partitionReferenceNum;
>
> Hello! I do not think that it make sense to report "free blocks" for
> discs with Virtual partition. By definition of VAT, all blocks prior to
> VAT are already "read-only" and therefore these blocks cannot be use for
> writing new data by any implementation. And because VAT is stored on the
> last block, in our model all blocks are "occupied".
Fair enough. Let's just always return 0 for disks with VAT partition.
> > + }
> >
> > - sbi = UDF_SB(sb);
> > if (sbi->s_lvid_bh) {
> > struct logicalVolIntegrityDesc *lvid =
> > (struct logicalVolIntegrityDesc *)
> > sbi->s_lvid_bh->b_data;
> > - if (le32_to_cpu(lvid->numOfPartitions) > sbi->s_partition) {
> > + if (le32_to_cpu(lvid->numOfPartitions) > part) {
> > accum = le32_to_cpu(
> > - lvid->freeSpaceTable[sbi->s_partition]);
> > + lvid->freeSpaceTable[part]);
>
> And in any case freeSpaceTable should not be used for discs with VAT.
> And we should ignore its value for discs with VAT.
>
> UDF 2.60 2.2.6.2: Free Space Table values be maintained ... except ...
> for a virtual partition ...
>
> And same applies for "partition with Access Type pseudo-overwritable".
Well this is handled by the 'accum == 0xffffffff' condition below. So we
effectively ignore these values.
> > if (accum == 0xFFFFFFFF)
> > accum = 0;
> > }
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-01-09 12:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 12:19 [PATCH] udf: Fix free space reporting for metadata and virtual partitions Jan Kara
2020-01-08 22:32 ` Pali Rohár
2020-01-09 12:44 ` Jan Kara [this message]
2020-01-09 12:56 ` Pali Rohár
2020-01-09 13:08 ` Pali Rohár
2020-01-09 16:53 ` Jan Kara
2020-01-12 12:23 ` Pali Rohár
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=20200109124405.GE22232@quack2.suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=pali.rohar@gmail.com \
/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.