linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vyacheslav Dubeyko <slava@dubeyko.com>
To: Sergei Antonov <saproj@gmail.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Anton Altaparmakov <aia21@cam.ac.uk>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Hin-Tak Leung <htl10@users.sourceforge.net>,
	Kyle Laracey <kalaracey@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hfsplus: fix "unused node is not erased" error
Date: Fri, 23 May 2014 10:21:34 +0400	[thread overview]
Message-ID: <1400826094.2406.10.camel@slavad-CELSIUS-H720> (raw)
In-Reply-To: <CABikg9zjhWmYt6+b2oTDZirkoDjzFJUiDs_feQbbBWW5LZcsOw@mail.gmail.com>

On Thu, 2014-05-22 at 15:18 +0200, Sergei Antonov wrote:
> On 22 May 2014 15:07, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
> > On Wed, 2014-05-21 at 20:15 +0200, Sergei Antonov wrote:
> >> On 21 May 2014 18:40, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
> >> > On Tue, 2014-05-20 at 19:44 +0200, Sergei Antonov wrote:
> >> >
> >> > [snip]
> >> >>
> >> >> -int hfsplus_file_extend(struct inode *inode)
> >> >> +int hfsplus_file_extend(struct inode *inode, bool zeroout)
> >> >>  {
> >> >>       struct super_block *sb = inode->i_sb;
> >> >>       struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
> >> >> @@ -463,6 +463,12 @@ int hfsplus_file_extend(struct inode *inode)
> >> >>               }
> >> >>       }
> >> >>
> >> >> +     if (zeroout) {
> >> >> +             res = sb_issue_zeroout(sb, start, len, GFP_NOFS);
> >> >
> >> > As I can see, sb_issue_zeroout() initiate request for write. But
> >> > previously the hfsplus_file_extend() operated by page cache only during
> >> > file extending. From one point of view, we can fail during operation of
> >> > file extending but, anyway, we will zero out blocks by means of writing.
> >>
> >> Which is not bad. Those blocks are free space.
> >>
> >
> > For me personally, proper place for sb_issue_zeroout() can be in
> > hfs_bmap_alloc() method
> > (http://lxr.free-electrons.com/source/fs/hfsplus/btree.c#L364):
> >
> >
> >         while (!tree->free_nodes) {
> >                 struct inode *inode = tree->inode;
> >                 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
> >                 u32 count;
> >                 int res;
> >
> >                 res = hfsplus_file_extend(inode);
> >                 if (res)
> >                         return ERR_PTR(res);
> >
> >                 /* here can be added sb_issue_zeroout() call */
> >
> >                 hip->phys_size = inode->i_size =
> >                         (loff_t)hip->alloc_blocks <<
> >                                 HFSPLUS_SB(tree->sb)->alloc_blksz_shift;
> >                 hip->fs_blocks =
> >                         hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift;
> >                 inode_set_bytes(inode, inode->i_size);
> >                 count = inode->i_size >> tree->node_size_shift;
> >                 tree->free_nodes = count - tree->node_count;
> >                 tree->node_count = count;
> >         }
> >
> > First of all, here we know that trying to extend file was successful.
> > And, secondly, hfs_bmap_alloc() method is dedicated b-tree case only.
> > I think that modification of hfsplus_file_extend() is not very good
> > idea. The hfs_bmap_alloc() method is more clear solution, from my
> > viewpoint.
> 
> hfs_bmap_alloc() does not know about volume blocks. It is on a higher
> level of abstraction. Try, as an experiment, to write a call to
> sb_issue_zeroout() passing correct arguments from hfs_bmap_alloc().
> 

The hfs_bmap_alloc() has pointer on hfsplus_inode_info structure of
btree's inode. The hfsplus_inode_info structure contains
hip->first_extents, hip->first_blocks, hip->cached_extents,
hip->cached_blocks and so on fields. Finally, hfsplus_file_extend()
method stores allocated extent in hip->first_extents or in
hip->cached_extents. So, I don't see anything impossible in calling
sb_issue_zeroout() with correct arguments from hfs_bmap_alloc(). Maybe
only to call sb_issue_zeroout() from hfsplus_file_extend() is more easy
way. But I think that placement this logic in hfs_bmap_alloc() is more
correct way, from architecture point of view.

Thanks,
Vyacheslav Dubeyko.



  reply	other threads:[~2014-05-23  6:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 17:44 [PATCH] hfsplus: fix "unused node is not erased" error Sergei Antonov
2014-05-21 16:40 ` Vyacheslav Dubeyko
2014-05-21 18:15   ` Sergei Antonov
2014-05-22 13:07     ` Vyacheslav Dubeyko
2014-05-22 13:18       ` Sergei Antonov
2014-05-23  6:21         ` Vyacheslav Dubeyko [this message]
2014-05-23 10:54           ` Sergei Antonov
  -- strict thread matches above, loose matches on Subject: below --
2014-05-21 20:12 Hin-Tak Leung
2014-05-22  6:29 ` Vyacheslav Dubeyko
2014-05-22  7:07   ` Andrew Morton
2014-05-22 12:48     ` Sergei Antonov
2014-05-22 13:13       ` Vyacheslav Dubeyko
2014-05-22 13:25         ` Sergei Antonov
2014-05-22 14:55           ` Vyacheslav Dubeyko
2014-05-22 17:35             ` Sergei Antonov

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=1400826094.2406.10.camel@slavad-CELSIUS-H720 \
    --to=slava@dubeyko.com \
    --cc=aia21@cam.ac.uk \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=htl10@users.sourceforge.net \
    --cc=kalaracey@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=saproj@gmail.com \
    --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 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).