Skip to contentSkip to conversation

ocfs2 quota qs.

Ocfs2-devel Tao Ma 2 participants 3 messages Jul 29, 2009 OCFS2

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

Hi Jan,
I am now reading quota support in ocfs2 and have some qs. Wish you can
help me clarify it. Thanks.

ocfs2_quota_write:
In the comment, you said that "we know the transaction is already
started", so it should be called within a transaction. But in this function, we call ocfs2_extend_no_holes and ocfs2_simple_size_update which will start another transaction. So we can survive with nested transaction or this scenario will never happen?

Regards,
Tao

#1 lore raw
Quoted 10 lines · Tao Ma

Hi Jan,
I am now reading quota support in ocfs2 and have some qs. Wish you can
help me clarify it. Thanks.

ocfs2_quota_write:
In the comment, you said that "we know the transaction is already
started", so it should be called within a transaction. But in this function, we call ocfs2_extend_no_holes and ocfs2_simple_size_update which will start another transaction. So we can survive with nested transaction or this scenario will never happen?

The comment is right, we absolutely require a transaction being started
when when entering ocfs2_quota_write(), otherwise deadlocks could occur.
JBD supports nested transactions - when journal_start() is called and
the current process already has a transaction open, it just returns the currently open transaction. So you only have to be sure to initially ask for enough credits when opening the transaction - and quota code hopefully gets this right.
Hmm, but looking at the code again, there's one catch - normally,
allocator locks nest outside the transaction and in ocfs2_quota_write() they are acquired inside the transaction and that can lead to deadlocks. Aw, that's going to be nasty to fix... I have to rethink the locking logic...
Thanks for your inquiry :)

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw
Quoted 13 lines · Jan Kara
Quoted 11 lines · Tao Ma

Hi Jan,
I am now reading quota support in ocfs2 and have some qs. Wish you can
help me clarify it. Thanks.

ocfs2_quota_write:
In the comment, you said that "we know the transaction is already
started", so it should be called within a transaction. But in this function, we call ocfs2_extend_no_holes and ocfs2_simple_size_update which will start another transaction. So we can survive with nested transaction or this scenario will never happen?

Quoted 14 lines

The comment is right, we absolutely require a transaction being started
when when entering ocfs2_quota_write(), otherwise deadlocks could occur.
JBD supports nested transactions - when journal_start() is called and
the current process already has a transaction open, it just returns the currently open transaction. So you only have to be sure to initially ask for enough credits when opening the transaction - and quota code hopefully gets this right.
Hmm, but looking at the code again, there's one catch - normally,
allocator locks nest outside the transaction and in ocfs2_quota_write() they are acquired inside the transaction and that can lead to deadlocks. Aw, that's going to be nasty to fix... I have to rethink the locking logic...
Thanks for your inquiry :)

Thank you for the explanation.

Regards,
Tao