From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Jan Koss <kossjan@gmail.com>
Cc: kernelnewbies@nl.linux.org, linux-fsdevel@vger.kernel.org
Subject: Re: fragmentation && blocks "realloc"
Date: Fri, 20 Jan 2006 20:04:09 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0601201955530.20740@hermes-2.csi.cam.ac.uk> (raw)
In-Reply-To: <b97d23040601200746x75b4c378l1b7b8516b8fdbf1e@mail.gmail.com>
On Fri, 20 Jan 2006, Jan Koss wrote:
> In fact, I expected yes for the first abbility and no for the second :)
>
> Now code looks like:
> bh = sb_bread(sb, oldblock);
> if (!bh)
> goto err;
> bh->b_blocknr = newblk;
> mark_buffer_dirty (bh);
> unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
No, no, no!!! You cannot do this. You are not using the page cache for
your file system (why not?) so you cannot remap buffers like I suggested.
Even if you could your code is wrong. You need the
unmap_underlying_metadata() _before_ mark_buffer_dirty().
> Let's suppose such test case:
> after situation, which I described in the first email,
> user resize file and new size 5 blocks,
> and there are no free blocks except 2 blocks which we deallocated in
> the frist email,
> so we have to allocate them.
>
> When I reproduced this test case, I got such messages from kernel:
> __find_get_block_slow failed block=oldblock...
>
> So as I can see I missed something in "art of changing b_blocknr".
>
> Error in __find_get_block_slow may happen only if all buffers on page mapped.
>
> May be this is because of buffer_head change b_blocknr, but didn't
> change b_this_page?
You cannot touch b_this_page on buffers you access via sb_bread(). The
correct solution for a file system like yours would be to copy the buffer
data to the correct buffer and write that and release the old one. I.e.
your first suggestion, i.e. do not touch b_blocknr or b_this_page. And
you do not need to call unmap_underlying_metadata() either or invalidate
any pages.
You are working with the block device directly. Bypassing the per file
page cache thus you cannot do anything to the buffers at all other than
read/write them.
It would be far better if you start using the page cache (via ->readpage,
->writepage, and probably ->prepare_write and ->commit_write as well) and
then from inside readpage/writepage/prepare_write/commit_write you can do
with the buffers as I suggested...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
prev parent reply other threads:[~2006-01-20 20:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-20 11:47 fragmentation && blocks "realloc" Jan Koss
2006-01-20 13:34 ` Anton Altaparmakov
2006-01-20 15:46 ` Jan Koss
2006-01-20 19:22 ` Jan Koss
2006-01-20 20:11 ` Anton Altaparmakov
2006-01-21 9:42 ` Jan Koss
2006-01-21 20:28 ` Anton Altaparmakov
2006-01-22 20:58 ` Jan Koss
2006-01-22 21:32 ` Anton Altaparmakov
2006-01-22 22:05 ` Jan Koss
2006-01-24 10:37 ` Anton Altaparmakov
2006-02-23 21:47 ` Nate Diller
2006-01-20 20:04 ` Anton Altaparmakov [this message]
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=Pine.LNX.4.64.0601201955530.20740@hermes-2.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=kernelnewbies@nl.linux.org \
--cc=kossjan@gmail.com \
--cc=linux-fsdevel@vger.kernel.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).