From: Theodore Ts'o <tytso@mit.edu>
To: xfs@oss.sgi.com
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] ext4: add a new spinlock i_raw_lock to protect the ext4's raw inode
Date: Sat, 12 Apr 2014 18:55:14 -0400 [thread overview]
Message-ID: <1397343317-14669-1-git-send-email-tytso@mit.edu> (raw)
To avoid potential data races, use a spinlock which protects the raw
(on-disk) inode.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/ext4.h | 2 ++
fs/ext4/inode.c | 5 ++++-
fs/ext4/super.c | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 86c2cda..1d08a1b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -875,6 +875,8 @@ struct ext4_inode_info {
struct inode vfs_inode;
struct jbd2_inode *jinode;
+ spinlock_t i_raw_lock; /* protects updates to the raw inode */
+
/*
* File creation time. Its function is same as that of
* struct timespec i_{a,c,m}time in the generic inode.
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2eb5fad..1ee8ff6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4311,7 +4311,9 @@ static int ext4_do_update_inode(handle_t *handle,
uid_t i_uid;
gid_t i_gid;
- /* For fields not not tracking in the in-memory inode,
+ spin_lock(&ei->i_raw_lock);
+
+ /* For fields not tracked in the in-memory inode,
* initialise them to zero for new inodes. */
if (ext4_test_inode_state(inode, EXT4_STATE_NEW))
memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
@@ -4419,6 +4421,7 @@ static int ext4_do_update_inode(handle_t *handle,
ext4_update_inode_fsync_trans(handle, inode, need_datasync);
out_brelse:
+ spin_unlock(&ei->i_raw_lock);
brelse(bh);
ext4_std_error(inode->i_sb, err);
return err;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c4895c1..1f8cb18 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -879,6 +879,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
return NULL;
ei->vfs_inode.i_version = 1;
+ spin_lock_init(&ei->i_raw_lock);
INIT_LIST_HEAD(&ei->i_prealloc_list);
spin_lock_init(&ei->i_prealloc_lock);
ext4_es_init_tree(&ei->i_es_tree);
--
1.9.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2014-04-12 22:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-12 22:55 Theodore Ts'o [this message]
2014-04-12 22:55 ` [PATCH 1/3] generic/004: fix filtering of expected error message Theodore Ts'o
2014-04-13 4:06 ` Eric Sandeen
2014-04-12 22:55 ` [PATCH 2/3] generic/022: update expected output after the test was renamed Theodore Ts'o
2014-04-13 4:07 ` Eric Sandeen
2014-04-12 22:55 ` [PATCH 3/3] generic/237: fix filtering for expected failure message Theodore Ts'o
2014-04-13 8:17 ` Christoph Hellwig
2014-04-13 12:43 ` Theodore Ts'o
2014-04-14 0:14 ` Dave Chinner
2014-04-15 2:08 ` Theodore Ts'o
2014-04-12 23:03 ` [PATCH] ext4: add a new spinlock i_raw_lock to protect the ext4's raw inode Theodore Ts'o
-- strict thread matches above, loose matches on Subject: below --
2014-04-12 17:14 Theodore Ts'o
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=1397343317-14669-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=xfs@oss.sgi.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 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).