All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 25/29] ocfs2: Implementation of local and global quota	file handling
Date: Thu, 20 Nov 2008 15:53:15 +0100	[thread overview]
Message-ID: <20081120145315.GC20118@duck.suse.cz> (raw)
In-Reply-To: <20081105224920.GW15154@wotan.suse.de>

  Hi Mark!

  Thanks for the review. Your comments which aren't deleted has been just
silently implemented :).

> > +static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
> > +{
> > +	struct ocfs2_global_disk_dqblk *d = dp;
> > +	struct mem_dqblk *m = &dquot->dq_dqb;
> > +
> > +	d->dqb_id = cpu_to_le32(dquot->dq_id);
> > +	d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count);
> > +	d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
> > +	d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
> > +	d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
> > +	d->dqb_bhardlimit = cpu_to_le64(m->dqb_bhardlimit);
> > +	d->dqb_bsoftlimit = cpu_to_le64(m->dqb_bsoftlimit);
> > +	d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
> > +	d->dqb_btime = cpu_to_le64(m->dqb_btime);
> > +	d->dqb_itime = cpu_to_le64(m->dqb_itime);
> > +	d->dqb_pad1 = d->dqb_pad2 = 0;
> 
> Just to be clear - do we definitely want to reset dqb_pad1 and dqb_pad2
> every time the header is written? This means that a future version of the
> quota code can't put values there without having them overwritten by nodes
> which don't understand the new fields...
  OK, done. Since the block is zeroed-out before it's reused, it's fine to
not zero padding fields. OTOH I suspect that we'll have to require all
nodes to understand new meaning of these fields when we start using them
anyway. The only advantage is we will not have to change disk layout.

> > +/* Write to quotafile (we know the transaction is already started and has
> > + * enough credits) */
> > +ssize_t ocfs2_quota_write(struct super_block *sb, int type,
> > +			  const char *data, size_t len, loff_t off)
> > +{
> > +	struct mem_dqinfo *info = sb_dqinfo(sb, type);
> > +	struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
> > +	struct inode *gqinode = oinfo->dqi_gqinode;
> > +	int offset = off & (sb->s_blocksize - 1);
> > +	sector_t blk = off >> sb->s_blocksize_bits;
> > +	int err = 0;
> > +	struct buffer_head *bh;
> > +	handle_t *handle = journal_current_handle();
> > +	size_t tocopy, towrite = len;
> > +
> > +	if (!handle) {
> > +		mlog(ML_ERROR, "Quota write (off=%llu, len=%llu) cancelled "
> > +		     "because transaction was not started.\n",
> > +		     (unsigned long long)off, (unsigned long long)len);
> > +		return -EIO;
> > +	}
> > +	mutex_lock_nested(&gqinode->i_mutex, I_MUTEX_QUOTA);
> > +	if (gqinode->i_size < off + len) {
> > +		down_write(&OCFS2_I(gqinode)->ip_alloc_sem);
> > +		err = ocfs2_extend_no_holes(gqinode, off + len, off);
> > +		up_write(&OCFS2_I(gqinode)->ip_alloc_sem);
> > +		if (err < 0)
> > +			goto out;
> > +		err = ocfs2_simple_size_update(gqinode,
> > +					       oinfo->dqi_gqi_bh,
> > +					       off + len);
> > +		if (err < 0)
> > +			goto out;
> 
> Is it safe if we crash / error here, after the size has been extended but
> before we've written into the newly allocated blocks? In particular, could
> we wind up reading those blocks later and wrongly interpreting whatever data
> happens to be there? Hmm ok, I guess ocfs2_zero_extend() from
> ocfs2_extend_no_holes() fixes that for you, but it's using the page cache.
> Does that interact reasonably with what we're doing below?
  It should work fine. I actually don't use ocfs2_zero_extend() (note that
I pass 'off' to ocfs2_extend_no_holes() as the third parameter). But when
generic quota code decides to extend the file, it checks whether the write
succeeded and if not, it just internally does not increase it's notion of
quotafile size.

> > +	}
> > +	WARN_ON(off >> sb->s_blocksize_bits != \
> > +		(off + len) >> sb->s_blocksize_bits);
> > +	WARN_ON(((off + len) & ((1 << sb->s_blocksize_bits) - 1)) >
> > +		sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE);
> > +	for (towrite = len; towrite > 0; towrite -= tocopy) {
> > +		tocopy = min(towrite, (size_t)(sb->s_blocksize - offset));
> > +		bh = ocfs2_read_quota_block(gqinode, blk, &err);
> > +		if (!bh) {
> > +			mlog_errno(err);
> > +			return err;
> > +		}
> > +		err = ocfs2_journal_access(handle, gqinode, bh,
> > +						OCFS2_JOURNAL_ACCESS_WRITE);
> > +		if (err < 0) {
> > +			brelse(bh);
> > +			goto out;
> > +		}
> 
> We can optimize away the disk read if the block is newly allocated. There's
> no need to read it off disk, so we can just sb_getblk() it. Likewise, you'd
> want to use OCFS2_JOURNAL_ACCESS_CREATE for those. How often does the quota
> file get extended though? If it's sufficiently rare, we could save this for
> later. Otherwise, it's probably worth the effort imho.
  Actually, extending quota file is really rare operation - happens only
once per 20 new users of the cluster :). But your comment got me an idea,
that we can save read in most rewrite cases because upper level quota code
provides us with a complete content of the block. So I've rewritten the
function to optimize this case. But please check whether the function is
right when I submit next version of patches.

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

  reply	other threads:[~2008-11-20 14:53 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 22:07 [Ocfs2-devel] [PATCH 00/00] Implement quotas for OCFS2 (version 2) Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 01/29] quota: Add callbacks for allocating and destroying dquot structures Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 02/29] quota: Increase size of variables for limits and inode usage Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 03/29] quota: Remove bogus 'optimization' in check_idq() and check_bdq() Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 04/29] quota: Make _SUSPENDED just a flag Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 05/29] quota: Allow to separately enable quota accounting and enforcing limits Jan Kara
2008-10-24 22:07 ` [Ocfs2-devel] [PATCH 06/29] ext3: Use sb_any_quota_loaded() instead of sb_any_quota_enabled() Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 07/29] ext4: " Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 08/29] reiserfs: " Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 09/29] quota: Remove compatibility function sb_any_quota_enabled() Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 10/29] quota: Introduce DQUOT_QUOTA_SYS_FILE flag Jan Kara
2008-10-29 23:09   ` Mark Fasheh
2008-10-30  7:24     ` Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 11/29] quota: Move quotaio_v[12].h from include/linux/ to fs/ Jan Kara
2008-10-29 23:10   ` Mark Fasheh
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 12/29] quota: Split off quota tree handling into a separate file Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 13/29] quota: Convert union in mem_dqinfo to a pointer Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 14/29] quota: Allow negative usage of space and inodes Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 15/29] quota: Keep which entries were set by SETQUOTA quotactl Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 16/29] quota: Add helpers to allow ocfs2 specific quota initialization, freeing and recovery Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 17/29] quota: Implement function for scanning active dquots Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 18/29] mm: Export pdflush_operation() Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 19/29] ocfs2: Fix check of return value of ocfs2_start_trans() Jan Kara
2008-10-30 23:34   ` Mark Fasheh
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 20/29] ocfs2: Support nested transactions Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 21/29] ocfs2: Fix checking of return value of new_inode() Jan Kara
2008-10-30 23:51   ` Mark Fasheh
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 22/29] ocfs2: Let inode be really deleted when ocfs2_mknod_locked() fails Jan Kara
2008-10-30 23:52   ` Mark Fasheh
2008-10-31  5:05     ` Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 23/29] ocfs2: Assign feature bits and system inodes to quota feature and quota files Jan Kara
2008-10-28 22:16   ` Joel Becker
2008-10-29  2:32     ` Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 24/29] ocfs2: Mark system files as not subject to quota accounting Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 25/29] ocfs2: Implementation of local and global quota file handling Jan Kara
2008-10-28 19:07   ` Joel Becker
2008-10-28 19:36   ` Joel Becker
2008-10-29  2:29     ` Jan Kara
2008-10-29 10:51       ` Joel Becker
2008-10-30  7:33         ` Jan Kara
2008-10-30 20:31           ` Joel Becker
2008-10-31  5:00             ` Jan Kara
2008-11-05 22:49   ` Mark Fasheh
2008-11-20 14:53     ` Jan Kara [this message]
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 26/29] ocfs2: Add quota calls for allocation and freeing of inodes and space Jan Kara
2008-11-06  0:06   ` Mark Fasheh
2008-11-20 15:19     ` Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 27/29] ocfs2: Implement quota syncing thread Jan Kara
2008-11-06  0:27   ` Mark Fasheh
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 28/29] ocfs2: Implement quota recovery Jan Kara
2008-11-06  0:52   ` Mark Fasheh
2008-11-20 16:51     ` Jan Kara
2008-10-24 22:08 ` [Ocfs2-devel] [PATCH 29/29] ocfs2: Enable quota accounting on mount, disable on umount Jan Kara
2008-10-28 19:11   ` Joel Becker
2008-10-29  2:30     ` 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=20081120145315.GC20118@duck.suse.cz \
    --to=jack@suse.cz \
    --cc=ocfs2-devel@oss.oracle.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 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.