Re: [patch 11/13] don't hold i_sem during O_DIRECT writes to blockdevs

Linus Torvalds (torvalds@transmeta.com)
Sun, 28 Jul 2002 17:47:39 -0700 (PDT)


On Sun, 28 Jul 2002, Andrew Morton wrote:
>
> We can do the rwsem thing, and that would be good. But there may
> be filesystems which are relying on i_sem to provide protection
> against concurrent invokations of get_block(create=1), inside i_size.

We actually want to retain i_sem for directory operations anyway (ie the
rw-semaphore would be an addition, not a replacement), so the easiest
transition would probably be to move the i_sem thing into the filesystems
when the rwsem thing is done (the same way the BKL removal worked), and
then let the filesystems make their own decisions on when they need it
(and the decision might well be to take it in the "create = 1" case, which
is likely to be fairly rare for non-extending writes)

The other alternative is to move this _all_ into the filesystem entirely,
and not have "generic_file_write()" take any lock at all. Let the
filesystem first take whatever lock it thinks it needs, and then call
"generic_file_write()". Filesystems migh choose to just get i_sem
unconditionally both for extending and non-extending writes.

That would mean that the filesystems would have to always wrap their use
of "generic_file_write()", but a number of them do so anyway because they
want to do some other book-keeping. I dunno.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/