From: Dmitry <dmonakhov@openvz.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, hch@infradead.org
Subject: Re: [PATCH 04/19] quota: protect dqget() from parallels quotaoff via SRCU
Date: Tue, 23 Nov 2010 00:53:59 +0300 [thread overview]
Message-ID: <87y68lja88.fsf@dmon-lap.sw.ru> (raw)
In-Reply-To: <20101122212121.GE6141@quack.suse.cz>
On Mon, 22 Nov 2010 22:21:21 +0100, Jan Kara <jack@suse.cz> wrote:
> On Thu 11-11-10 15:14:23, Dmitry Monakhov wrote:
> > In order to hide quota internals inside didicated structure pointer.
> > We have to serialize that object lifetime with dqget(), and change/uncharge
> > functions.
> > Quota_info construction/destruction will be protected via ->dq_srcu.
> > SRCU counter temproraly placed inside sb, but will be moved inside
> > quota object pointer in next patch.
> The changelog seems rather insufficient to me. Could you please write
> here the new locking rules more in detail? What structures are exactly
> protected by RCU? Which lock are you able to relax after these changes (is
> it only dq_state_lock?)? The rules should be also placed in dquot.c where
> locking is described.
Unfortunately you right, comments are not very descriptive, will redo.
>
> > diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> > index 748d744..7e937b0 100644
> > --- a/fs/quota/dquot.c
> > +++ b/fs/quota/dquot.c
> > @@ -805,7 +805,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
> > /*
> > * Get reference to dquot
> > *
> > - * Locking is slightly tricky here. We are guarded from parallel quotaoff()
> > + * We are guarded from parallel quotaoff() by holding srcu_read_lock
> The comment does not make sense after your change anymore.
>
> > * destroying our dquot by:
> > * a) checking for quota flags under dq_list_lock and
> > * b) getting a reference to dquot before we release dq_list_lock
> > @@ -814,9 +814,15 @@ struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
> > {
> > unsigned int hashent = hashfn(sb, id, type);
> > struct dquot *dquot = NULL, *empty = NULL;
> > + int idx;
> >
> > - if (!sb_has_quota_active(sb, type))
> > + rcu_read_lock();
> > + if (!sb_has_quota_active(sb, type)) {
> > + rcu_read_unlock();
> > return NULL;
> > + }
> > + idx = srcu_read_lock(&dqopts(sb)->dq_srcu);
> > + rcu_read_unlock();
> Ugh, I'm kind of puzzled by your combination of RCU and SRCU. What's the
> point?
This is just a trick for non static srcu variables, to prevent
races between use/free, see http://lwn.net/Articles/202847/
In my case i implement it like follows
/* All readers do */
rcu_read_lock();
/* Stage1: at this moment we prevent dq_srcu from being fried */
if (!sb_has_quota_active(sb, type)) {
rcu_read_unlock();
return NULL;
}
/* Stage2: grab reference to quota_info. */
idx = srcu_read_lock(&dqopts(sb)->dq_srcu);
rcu_read_unlock();
/* quota_disable: Cleanup path looks like this */
quota_clear_active(sb, type);
/* Wait for all callers in stage1 */
synchronize_rcu();
/* Wait for all caller in stage2 */
synchronize_srcu(&dqopts(sb)->dq_srcu);
/* Now we can finely destroy srcu pointer
cleanup_srcu(&dqopts(sb)->dq_srcu);
>
> Honza
> --
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-11-22 21:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-11 12:14 [PATCH 00/19] quota: RFC SMP improvements for generic quota V3 Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 01/19] quota: protect getfmt call with dqonoff_mutex lock Dmitry Monakhov
2010-11-11 13:36 ` Christoph Hellwig
2010-11-22 19:35 ` Jan Kara
2010-12-02 11:40 ` Dmitry
2010-11-11 12:14 ` [PATCH 02/19] kernel: add bl_list Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 03/19] quota: Wrap common expression to helper function Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 04/19] quota: protect dqget() from parallels quotaoff via SRCU Dmitry Monakhov
2010-11-22 21:21 ` Jan Kara
2010-11-22 21:53 ` Dmitry [this message]
2010-11-11 12:14 ` [PATCH 05/19] quota: mode quota internals from sb to quota_info Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 06/19] quota: Remove state_lock Dmitry Monakhov
2010-11-22 21:12 ` Jan Kara
2010-11-22 21:31 ` Dmitry
2010-11-23 10:55 ` Jan Kara
2010-11-23 11:33 ` Jan Kara
2010-11-11 12:14 ` [PATCH 07/19] quota: add quota format lock Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 08/19] quota: make dquot lists per-sb Dmitry Monakhov
2010-11-22 21:37 ` Jan Kara
2010-11-11 12:14 ` [PATCH 09/19] quota: optimize quota_initialize Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 10/19] quota: user per-backet hlist lock for dquot_hash Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 11/19] quota: remove global dq_list_lock Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 12/19] quota: rename dq_lock Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 13/19] quota: make per-sb dq_data_lock Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 14/19] quota: protect dquot mem info with object's lock Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 15/19] quota: drop dq_data_lock where possible Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 16/19] quota: relax dq_data_lock dq_lock locking consistency Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 17/19] quota: Some stylistic cleanup for dquot interface Dmitry Monakhov
2010-11-23 11:37 ` Jan Kara
2010-11-11 12:14 ` [PATCH 18/19] fs: add unlocked helpers Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 19/19] quota: protect i_dquot with i_lock instead of dqptr_sem Dmitry Monakhov
2010-11-19 5:44 ` [PATCH 00/19] quota: RFC SMP improvements for generic quota V3 Dmitry
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=87y68lja88.fsf@dmon-lap.sw.ru \
--to=dmonakhov@openvz.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.