From: Dmitry Monakhov <dmonakhov@openvz.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, hch@infradead.org, sandeen@redhat.com
Subject: Re: [PATCH 3/6] quota: Check what quota is properly initialized for inode before charge
Date: Mon, 17 May 2010 10:22:54 +0400 [thread overview]
Message-ID: <87vdan59oh.fsf@openvz.org> (raw)
In-Reply-To: <20100507164810.GG3700@quack.suse.cz> (Jan Kara's message of "Fri, 7 May 2010 18:48:10 +0200")
Jan Kara <jack@suse.cz> writes:
> On Thu 08-04-10 22:04:22, Dmitry Monakhov wrote:
>> Due to previous IO error or other bugs an inode may not has quota
>> pointer. This definite sign of quota inconsistency/corruption.
>> In fact this condition must being checked in all charge/uncharge
>> functions. And if error was detected it is reasonable to fail whole
>> operation. But uncharge(free_space/claim_space/free_inode) functions
>> has no fail nature. This is because caller can't handle errors from
>> such functions. How can you handle error from following call-trace?
>> write_page()->quota_claim_space()
>>
>> So alloc_space() and alloc_inode() are the only functions which we may
>> reliably abort in case of any errors.
>>
>> This patch add corresponding checks only for charge functions.
>>
>> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
>> ---
>> fs/quota/dquot.c | 39 +++++++++++++++++++++++++++++++++------
>> 1 files changed, 33 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
>> index 3f4541e..7480e03 100644
>> --- a/fs/quota/dquot.c
>> +++ b/fs/quota/dquot.c
>> @@ -1529,13 +1529,27 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
>> }
>>
>> down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
>> + /* Now recheck reliably when holding dqptr_sem */
>> + if (!(active = sb_any_quota_active(inode->i_sb)) || IS_NOQUOTA(inode)) {
> Please don't use assignment in conditions... It's against kernel's coding
> style.
>
>> + inode_incr_space(inode, number, reserve);
>> + goto out;
>> + }
>> +
>> for (cnt = 0; cnt < MAXQUOTAS; cnt++)
>> warntype[cnt] = QUOTA_NL_NOWARN;
>>
>> spin_lock(&dq_data_lock);
>> for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
>> - if (!inode->i_dquot[cnt])
>> + if (!(active & (1 << cnt)))
>> continue;
>> + /*
>> + * Given quota type is active, so quota must being
>> + * initialized for this inode
>> + */
>> + if (!inode->i_dquot[cnt]) {
>> + ret = -EIO;
> Umm, I don't like this. I think we should just silently skip the quota
> modification. The error has already been passed to the filesystem during
> dquot_initialize and this would effectively disallow any allocation on the
> filesystem if quota structure isn't available which might be a bit
> impractical.
In fact in many places ret code from dquot_initialize() is simply
ignored, because before this patch-set init was void, so it takes
significant amount of time to fix all callers. And charge callers are
usually do care about error code, so IMHO we have to signal what
quota is broken if it is actually broken.
Another example: If filesystem becomes RO (due to journal abort, and etc)
we do care about this, and check that condition in almost all places and
return appropriate error, instead of simply skip write() syscall.
User is able to disable quota if it becomes broken, and continue with
hope that this is just an quota issue, but not disk failure :)
next prev parent reply other threads:[~2010-05-17 6:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 18:04 [PATCH 0/6] RFC quota: Redesign IO error handling interface Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 1/6] quota: unify quota init condition in setattr Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 2/6] quota: Add proper error handling on quota initialization Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 3/6] quota: Check what quota is properly initialized for inode before charge Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 4/6] ext3: handle errors in orphan_cleanup Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 5/6] ext4: " Dmitry Monakhov
2010-04-08 18:04 ` [PATCH 6/6] quota: check error code from dquot_initialize Dmitry Monakhov
2010-05-07 17:01 ` Jan Kara
2010-05-07 16:59 ` [PATCH 4/6] ext3: handle errors in orphan_cleanup Jan Kara
2010-05-07 16:48 ` [PATCH 3/6] quota: Check what quota is properly initialized for inode before charge Jan Kara
2010-05-17 6:22 ` Dmitry Monakhov [this message]
2010-05-07 16:44 ` [PATCH 2/6] quota: Add proper error handling on quota initialization Jan Kara
2010-05-07 16:39 ` [PATCH 1/6] quota: unify quota init condition in setattr Jan Kara
2010-05-13 16:29 ` Jan Kara
2010-05-05 8:45 ` [PATCH 0/6] RFC quota: Redesign IO error handling interface Dmitry Monakhov
2010-05-07 16:38 ` Jan Kara
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=87vdan59oh.fsf@openvz.org \
--to=dmonakhov@openvz.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sandeen@redhat.com \
/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).