From: Al Viro <viro@ftp.linux.org.uk>
To: Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/5]: ufs: missed brelse and wrong baseblk
Date: Sun, 18 Jun 2006 18:50:45 +0100 [thread overview]
Message-ID: <20060618175045.GX27946@ftp.linux.org.uk> (raw)
In-Reply-To: <20060618162054.GW27946@ftp.linux.org.uk>
On Sun, Jun 18, 2006 at 05:20:54PM +0100, Al Viro wrote:
> Comment more on the entire series than on this patch: scenario that causes
> trouble
> * foo is a sparse file on ufs with 8Kb block/1Kb fragment
> * process opens it writable and mmaps it shared
> * it proceeds to dirty the pages
> * fork
> * parent and child do msync() on pages next to each other
>
> I.e. we try to write adjacent pages that sit in the same block. At the
> same time. Each will trigger an allocation and we'd better be very
> careful, or we'll end up allocating the same block twice.
FWIW, for folks who are not familiar with UFS: the important differences
between it and ext2 are
* directory chunk size is fixed to 512, instead of being fs parameter
as in ext2
* names in directory entries are NUL-terminated
* there are two allocation units: fragment and block. Each block
consists of 2^{parameter} fragments. ext2 is what you get when parameter
is 0 (block == fragment). UFS tends to use block:fragment == 8, but
1, 2 and 4 are also allowed.
* equivalent of ext2 free block bitmap has bit per fragment.
* "block" in "direct block", "indirect block", etc. is actually
a group of fragments. The number of first fragment in group is stored
where ext2 would store the block number.
* if there are indirect blocks, all those groups are simply full
blocks; they are aligned to block boundary and consist of block:fragment
ratio fragments.
* if file is shorter than 12 * block size, we have no indirects and
all but the last direct one are full blocks. I.e. the numbers we have
there are multiples of block:fragment ration and a full block is allocated
for each. The last one consists of just enough fragments to reach the
end of file and may be not aligned.
IOW, it's _almost_ as if we had ext2 with all block numbers (in inode and
in indirect blocks) multiplied by block:fragment ratio. The only exception
is for the last direct block of small files - these span fewer fragments
and may be unaligned.
The only subtle part is when we extend a small file; the last direct block
needs to be expanded and that may require relocation.
* block may be bigger than page. That can cause all sorts of fun
problems in interaction with our VM, since allocation can affect more than
one page and that has to be taken into account.
* UFS2 supports ext.attributes; it has two fragment numbers in
inode; they refer to up to 2 blocks worth of data. As with the data
of small files, the partial block doesn't have to be aligned.
next prev parent reply other threads:[~2006-06-18 17:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-17 10:14 [PATCH 1/5]: ufs: missed brelse and wrong baseblk Evgeniy Dushistov
2006-06-18 16:20 ` Al Viro
2006-06-18 17:50 ` Al Viro [this message]
2006-06-19 6:47 ` Evgeniy Dushistov
2006-06-19 7:32 ` Al Viro
2006-06-19 13:17 ` Evgeniy Dushistov
2006-06-19 18:28 ` Al Viro
2006-06-19 18:58 ` Evgeniy Dushistov
2006-06-19 19:13 ` Al Viro
2006-06-20 16:30 ` Evgeniy Dushistov
2006-06-20 16:30 ` Evgeniy Dushistov
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=20060618175045.GX27946@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).