linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vyacheslav Dubeyko <slava-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
To: Ryusuke Konishi
	<konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Clemens Eisserer
	<linuxhippy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v3] nilfs2: implement calculation of free inodes count
Date: Fri, 17 May 2013 11:07:03 +0400	[thread overview]
Message-ID: <1368774423.2970.5.camel@slavad-ubuntu> (raw)
In-Reply-To: <20130517.014452.397311903.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>

Hi Ryusuke,

On Fri, 2013-05-17 at 01:44 +0900, Ryusuke Konishi wrote:
> On Thu, 16 May 2013 10:54:45 +0400, Vyacheslav Dubeyko wrote:
> > Hi Ryusuke,
> > 
> > On Thu, 2013-05-16 at 07:59 +0900, Ryusuke Konishi wrote:
> > 
> > [snip]
> >> > 
> >> > This patch still has a potential overflow issue that I pointed out in
> >> > the previous comment; the patch handles the number of descriptor
> >> > blocks in 32-bit wide variables without checking its upper limit.
> >> > 
> >> > If you won't to add checks for the number of descriptor blocks, I
> >> > propose you to change the definition of nilfs_palloc_groups_count() instead:
> >> > 
> >> >   static inline unsigned long
> >> >   nilfs_palloc_groups_count(const struct inode *inode)
> >> >   {
> >> > - 	return 1UL << (BITS_PER_LONG - (inode->i_blkbits + 3 /* log2(8) */));
> >> > + 	return nilfs_palloc_groups_per_desc_block(inode) << 32;
> >> >   }
> >> > 
> > 
> > I think the real reason of problem is in using constants (BITS_PER_LONG
> > for the first case and 32 for the second one). But, anyway, it makes
> > sense to operate by volume size in this calculation. Because namely
> > volume size is the real limitation for calculation of maximum available
> > groups count.
> > 
> > What do you think about using volume size in this calculation?
> > 
> > With the best regards,
> > Vyacheslav Dubeyko.
> 
> I disagree with using volume size because it makes resize logic much
> harder especially for shrink logic.  It requires reconstructing of
> ifile and DAT meatadata file.
> 
> I just want to fix the calculation of the maximum number of groups so
> that the number of descriptor blocks doesn't overflow both for 64-bit
> and 32-bit architectures.
> 

Ok. I see.

What about such implementation?

static inline unsigned long
nilfs_palloc_groups_count(const struct inode *inode)
{
#define NILFS_DESC_BLOCKS_MAX UINT_MAX
	return nilfs_palloc_groups_per_desc_block(inode) *
			(unsigned long)NILFS_DESC_BLOCKS_MAX;
#undef NILFS_DESC_BLOCKS_MAX
}

With the best regards,
Vyacheslav Dubeyko.

> Regards,
> Ryusuke Konishi
> 
> 
> >> > This implies the maximum number of descriptor block is 1 ^ 32.
> >> > 
> >> > Because the above diff changes the maximum number of groups, I think
> >> > it should be inserted as a separate patch.
> >> 
> >> Oops, sorry, this change can overflow in 32-bit architectures
> >> because the type of return value is still unsigned long.
> >> That calculation should be revised more carefully.
> >> 
> >> Ryusuke Konishi
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> >> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-05-17  7:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15 13:32 [PATCH v3] nilfs2: implement calculation of free inodes count Vyacheslav Dubeyko
2013-05-15 17:46 ` Ryusuke Konishi
     [not found]   ` <20130516.024602.67896918.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2013-05-15 22:59     ` Ryusuke Konishi
     [not found]       ` <20130516.075913.157469255.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2013-05-16  6:54         ` Vyacheslav Dubeyko
2013-05-16 16:44           ` Ryusuke Konishi
     [not found]             ` <20130517.014452.397311903.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2013-05-17  7:07               ` Vyacheslav Dubeyko [this message]
2013-05-17 18:18                 ` Ryusuke Konishi
2013-05-18 11:33                   ` Ryusuke Konishi

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=1368774423.2970.5.camel@slavad-ubuntu \
    --to=slava-yeenwd64clxbdgjk7y7tuq@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org \
    --cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linuxhippy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).