diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2013-01-29 10:14:48 +0000 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-20 12:59:09 -0500 |
commit | 87533c475187c1420794a2e164bc67a7974f1327 (patch) | |
tree | 699709da85c0a6c284cf37fe7026fbaf4768e6ab /fs/btrfs/file.c | |
parent | de98ced9e743656d108de41841797def0f5cb951 (diff) | |
download | blackbird-op-linux-87533c475187c1420794a2e164bc67a7974f1327.tar.gz blackbird-op-linux-87533c475187c1420794a2e164bc67a7974f1327.zip |
Btrfs: use bit operation for ->fs_state
There is no lock to protect fs_info->fs_state, it will introduce
some problems, such as the value may be covered by the other task
when several tasks modify it. For example:
Task0 - CPU0 Task1 - CPU1
mov %fs_state rax
or $0x1 rax
mov %fs_state rax
or $0x2 rax
mov rax %fs_state
mov rax %fs_state
The expected value is 3, but in fact, it is 2.
Though this problem doesn't happen now (because there is only one
flag currently), the code is error prone, if we add other flags,
the above problem will happen to a certainty.
Now we use bit operation for it to fix the above problem.
In this way, we can make the code more robust and be easy to
add new flags.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 13c78ea3ebce..75d0fe134be3 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1545,7 +1545,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, * although we have opened a file as writable, we have * to stop this write operation to ensure FS consistency. */ - if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { + if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) { mutex_unlock(&inode->i_mutex); err = -EROFS; goto out; |