From: Mark Fasheh <mfasheh@suse.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 1/1] ocfs2: Add extended attribute support v3
Date: Mon, 4 Aug 2008 14:34:04 -0700 [thread overview]
Message-ID: <20080804213404.GO28014@wotan.suse.de> (raw)
In-Reply-To: <489187C8.7030708@oracle.com>
On Thu, Jul 31, 2008 at 05:37:12PM +0800, Tiger Yang wrote:
> Mark Fasheh wrote:
> >The thing is, the locking as you have it here isn't protecting against
> >racing a data write, which is reading l_count on the extent list (or
> >id_count on
> >inline data) and an xattr write which might want to shrink those. You'll
> >need at least ip_alloc_sem around those, since ocfs2_page_mkwrite() doesn't
> >take i_mutex because it doesn't want to deadlock against the mmap
> >semaphore.
> Thanks, You point out a potential bug in my patch. I didn't protect
> reading/writing xattr against file data.
>
> My patch check l_count/id_count in ocfs2_xattr_has_space_inline() and
> may change it in ocfs2_xattr_ibody_set().
> is patch attached fix this problem?
In order to protect against mmap changing the inline data state, you should
hold a write lock on ip_alloc_sem across the call to ocfs2_xattr_ibody_find()
and until the return from ocfs2_xattr_set_entry.
So basically, ocfs2_xattr_set() should look like:
...
down_write(&oi->ip_alloc_sem);
ocfs2_ibody_find();
...
ocfs2_xattr_set_entry();
up_write(&oi->ip_alloc_sem);
...
This way mmap can't change inline data state in between the calls to
ibody_find and xattr_set_entry.
By the way, are operations that change or add xattrs protected by i_mutex?
It looks like we might want that too.
> >Or are you trying to protect xattr against itself? If that's the case, you
> >could push this lock up to the top and take it around entire operations.
> Actually I am trying to protect xattr read/write by this semaphore,
> since we found a bug about it.
> http://oss.oracle.com/bugzilla/show_bug.cgi?id=990
>
> So I need change comment about xattr semaphore.
> /* protects extended attribute change on this inode */
You could, or how about we just take i_mutex at the top of our xattr
operations for now? If we need the extra performance that more complicated
locking gives us, we can add this later.
--Mark
--
Mark Fasheh
next prev parent reply other threads:[~2008-08-04 21:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-25 21:57 [Ocfs2-devel] [PATCH 1/1] ocfs2: Add extended attribute support v3 Mark Fasheh
2008-07-31 9:37 ` Tiger Yang
2008-08-04 21:34 ` Mark Fasheh [this message]
2008-08-05 2:39 ` Tao Ma
2008-08-05 3:51 ` Mark Fasheh
2008-08-05 4:31 ` Tao Ma
2008-08-06 2:34 ` Tiger Yang
2008-08-06 22:14 ` Mark Fasheh
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=20080804213404.GO28014@wotan.suse.de \
--to=mfasheh@suse.com \
--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.