All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Erez Zadok <ezk@cs.sunysb.edu>
Cc: ezk@cs.sunysb.edu, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
	hch@infradead.org, mhalcrow@us.ibm.com, hugh@veritas.com
Subject: Re: [2.6.26 PATCH, RESEND]: fs_stack/eCryptfs: fsstack_copy_* updates
Date: Thu, 1 May 2008 17:08:19 -0700	[thread overview]
Message-ID: <20080501170819.bdcb9035.akpm@linux-foundation.org> (raw)
In-Reply-To: <200805012344.m41NiImk013312@agora.fsl.cs.sunysb.edu>

On Thu, 1 May 2008 19:44:18 -0400
Erez Zadok <ezk@cs.sunysb.edu> wrote:

> In message <20080501122136.bc2215c9.akpm@linux-foundation.org>, Andrew Morton writes:
> > On Thu, 1 May 2008 13:18:09 -0400
> > Erez Zadok <ezk@cs.sunysb.edu> wrote:
> > 
> > > In message <20080430101704.9cbd6384.akpm@linux-foundation.org>, Andrew Morton writes:
> > > [...[
> > > > Can we avoid having to think?
> > > > 
> > > > void fsstack_copy_inode_size(struct inode *dst, const struct inode *src)
> > > > {
> > > > 	blkcnt_t i_blocks;
> > > > 	loff_t i_size;
> > > > 
> > > > 	i_size = i_size_read(src);
> > > > 	spin_lock_32bit(&src->i_lock);
> > > > 	i_blocks = src->i_blocks;
> > > > 	spin_unlock_32bit(&src->i_lock);
> > > > 
> > > > 	i_size_write(dst, i_size);
> > > > 	spin_lock_32bit(&dst->i_lock)
> > > > 	dst->i_blocks = i_blocks;
> > > > 	spin_unlock_32bit(&dst->i_lock)
> > > > }
> > > 
> > > I can't find spin_[um]lock_32bit anywhere (checkd latest mmotm and linus's
> > > tree).  I therefore assume this was just your way of saying I should:
> > > 
> > > #if BITS_PER_LONG == 32
> > > 	spin_unlock(&dst->i_lock);
> > > #endif
> > 
> > Nope, it was my way of suggesting that you implement it ;)
> > include/linux/spinlock.h would be a good place.
> 
> Sure, I can implement it and submit a patch.  But I've got two questions
> first:
> 
> 1. i_size_read has a tri-state behaviour:
> 
> #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
> 	// play with seqcount
> #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
> 	// wrap in preempt_disable/enable
> #else
> 	// just return value
> #endif
> 
> Shouldn't the same be done for i_blocks, with matching i_blocks_read(),
> i_blocks_write(), and adding an inode->i_blocks_seqcount field?

I guess so, yes.  Maybe there are other things too.  We just haven't cared
enough to do all this fuss for i_blocks.  Even i_size was a bit marginal.

i_size is much more important because glitches in there can result in
incorrect data being returned from read() and things like that.  i_blocks
is just a beancounting curiosity.

> 
> 2. I've rewritten your suggested code a bit to reduce stack use.  Modulo
>    having 32-bit spin_lock/unlock variants, do you see any problem with this
>    code below?  My testing of it so far on 32/64-bit SMP/UMP have all
>    passed.
> 
> void fsstack_copy_inode_size(struct inode *dst, struct inode *src)
> {
> #if BITS_PER_LONG == 32
> 	blkcnt_t i_blocks;
> 
> 	spin_lock(&src->i_lock);
> 	i_blocks = src->i_blocks;
> 	spin_unlock(&src->i_lock);
> 	spin_lock(&dst->i_lock);
> 	dst->i_blocks = i_blocks;
> 	spin_unlock(&dst->i_lock);
> #else
> 	dst->i_blocks = src->i_blocks;
> #endif
> 	i_size_write(dst, i_size_read(src));
> }

That looks sane, as long as we don't care about i_size-vs-i_blocks
coherency.

However I expect that approximately zero of the sites which modify i_blocks
are taking i_lock to do so.

otoh, many of them _will_ accidentally have i_mutex coverage.  On the
write() path at least.  What happened to that idea?

  reply	other threads:[~2008-05-02  0:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21  6:50 [2.6.26 PATCH, RESEND]: fs_stack/eCryptfs: fsstack_copy_* updates Erez Zadok
2008-04-30 17:17 ` Andrew Morton
2008-04-30 21:09   ` Erez Zadok
2008-04-30 21:25     ` Andrew Morton
2008-05-01 17:18   ` Erez Zadok
2008-05-01 19:21     ` Andrew Morton
2008-05-01 23:44       ` Erez Zadok
2008-05-02  0:08         ` Andrew Morton [this message]
2008-05-02  5:58           ` Erez Zadok
2008-05-02  6:11             ` Andrew Morton
2008-05-12  0:44             ` hooanon05
2008-05-02 13:17   ` Hugh Dickins

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=20080501170819.bdcb9035.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ezk@cs.sunysb.edu \
    --cc=hch@infradead.org \
    --cc=hugh@veritas.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhalcrow@us.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /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.