linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Dmitry <dmonakhov@openvz.org>
Cc: Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, hch@infradead.org,
	Dmitry Monakhov <dmonakhov@gmail.com>
Subject: Re: [PATCH 09/11] quota: protect dquot mem info with objects's lock
Date: Wed, 6 Oct 2010 15:41:56 +0200	[thread overview]
Message-ID: <20101006134156.GN3676@quack.suse.cz> (raw)
In-Reply-To: <87wrpv8nqo.fsf@dmon-lap.sw.ru>

On Wed 06-10-10 17:17:03, Dmitry wrote:
> Later i've plans to get rid of dqptr_sem by rearranging code like follows.
> But may be i've introduced copy logic too soon.
> 
> Variant (1)
>   1) Protect i_dquot dereference/modification with i_lock
>   So charge/free function will looks like follows
>   do_alloc_space (struct inode* inode, qsize_t num)
>   {
>       spin_lock(&inode->i_lock);
>       if (!check_bdq(inode->i_dquot, num))
>             return EQDUOT;
>       inode_add_bytes_unlocked(inode, num);
>       dquot_add_bytes(inode->i_dquot, num); 
>       /* We can sleep while we call quota dirty, to protect quota from
>        * being deleted we have to get ref for the quota.
>        */
>       atomic_inc(dquot->dq_count);
>       dquot = inode->i_dquot;
>       spin_unlock(&inode->i_lock);
>       /* i_lock was dropped, do not touch i_dquot any more */
>       mark_dquot_dirty(dquot);
>       dqput(dquot);
>   }
> This is beter than before, but we still have massive anomic operations
> So we can try second variant.
>  
> Variant (2) 
>   do_alloc_space(struct inode* inode, qsize_t num)
>   {
>       idx = srcu_read_lock(&dqptr)
>       spin_lock(&inode->i_lock);
>       if (!check_bdq(inode->i_dquot, num))
>             return EQDUOT;
>       inode_add_bytes_unlocked(inode, num);
>       dquot_add_bytes(inode->i_dquot, num); 
>       /* We can sleep while we call quota dirty,
>        * But this is ok since quota deletion is protected by SRCU
>        * The only thing we have do is to save old i_dquot array
>        */
>       dquot = inode->i_dquot;
>       spin_unlock(&inode->i_lock);
>       /* i_lock was dropped, do not touch i_dquot any more */
>       mark_dquot_dirty(dquot);
>       srcu_read_unlock(&dqptr, idx);
>   }
>    /* Destroy method may looks like whis, it will be called from
>       background work.
>     */
>    do_destroy_quotas_loop() {
>       /* Wait for all quotas in free list */ 
>       synchronize_srcu(dqptr&)
>       /* 
>          Ok now we can safely destroy all quotas in the list,
>          Some of them may be dirty, so we have to write it first.
>        */
>       list_for_each_entry(dquot, &free_list, dq_free)
>             dquot_release(dquot);
> 
>    }
  I see. Protecting dquots with RCU seems like a reasonable thing to do
and then I agree you'd need to copy the dquot pointers. But for now please
refrain from doing so. Thanks.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2010-10-06 13:42 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 18:20 (unknown), Dmitry Monakhov
2010-10-05 18:20 ` [PATCH 01/11] quota: add wrapper function Dmitry Monakhov
2010-10-06  8:56   ` Christoph Hellwig
2010-10-06 10:01   ` Jan Kara
2010-10-05 18:20 ` [PATCH 02/11] quota: Convert dq_state_lock to per-sb dq_state_lock Dmitry Monakhov
2010-10-06 10:04   ` Jan Kara
2010-10-05 18:20 ` [PATCH 03/11] quota: add quota format lock Dmitry Monakhov
2010-10-06 10:05   ` Jan Kara
2010-10-05 18:20 ` [PATCH 04/11] quota: make dquot lists per-sb Dmitry Monakhov
2010-10-06  8:57   ` Christoph Hellwig
2010-10-06  9:39     ` Dmitry
2010-10-06 10:22   ` Jan Kara
2010-10-06 10:40     ` Dmitry
2010-10-06 10:54       ` Jan Kara
2010-10-05 18:20 ` [PATCH 05/11] quota: make per-sb hash array Dmitry Monakhov
2010-10-06 10:38   ` Jan Kara
2010-10-05 18:20 ` [PATCH 06/11] quota: remove global dq_list_lock Dmitry Monakhov
2010-10-05 18:20 ` [PATCH 07/11] quota: rename dq_lock Dmitry Monakhov
2010-10-05 18:20 ` [PATCH 08/11] quota: make per-sb dq_data_lock Dmitry Monakhov
2010-10-06 11:01   ` Jan Kara
2010-10-05 18:20 ` [PATCH 09/11] quota: protect dquot mem info with objects's lock Dmitry Monakhov
2010-10-06 12:37   ` Jan Kara
2010-10-06 13:17     ` Dmitry
2010-10-06 13:41       ` Jan Kara [this message]
2010-10-06 14:19     ` Dmitry
2010-10-06 13:30   ` Jan Kara
2010-10-06 13:41     ` Dmitry
2010-10-05 18:20 ` [PATCH 10/11] quota: drop dq_data_lock where possible Dmitry Monakhov
2010-10-05 18:20 ` [PATCH 11/11] quota: relax dq_data_lock dq_lock locking consistency Dmitry Monakhov
2010-10-06 11:56   ` Jan Kara
2010-10-06  7:08 ` [PATCH 0/11] RFC quota scalability V1 Dmitry
2010-10-06  9:44   ` Jan Kara
2010-10-06 10:15     ` Dmitry
2010-10-06 10:47       ` Jan Kara
2010-10-10  3:50     ` Brad Boyer

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=20101006134156.GN3676@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=dmonakhov@gmail.com \
    --cc=dmonakhov@openvz.org \
    --cc=hch@infradead.org \
    --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 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).