Some of the spinlock_t ip_lock protection scopes are incorrect and
should follow the usage in 'struct ocfs2_inode_info'.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
Reviewed-by: Su Yue <glass.su@suse.com>
---
fs/ocfs2/dlmglue.c | 3 ++-
fs/ocfs2/inode.c | 5 +++--
fs/ocfs2/resize.c | 4 ++--
fs/ocfs2/suballoc.c | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index da78a04d6f0b..4a5900c8dc8f 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2232,6 +2232,8 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
else
inode->i_blocks = ocfs2_inode_sector_count(inode);
+ spin_unlock(&oi->ip_lock);
+
i_uid_write(inode, be32_to_cpu(lvb->lvb_iuid));
i_gid_write(inode, be32_to_cpu(lvb->lvb_igid));
inode->i_mode = be16_to_cpu(lvb->lvb_imode);
@@ -2242,7 +2244,6 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
inode_set_mtime_to_ts(inode, ts);
ocfs2_unpack_timespec(&ts, be64_to_cpu(lvb->lvb_ictime_packed));
inode_set_ctime_to_ts(inode, ts);
- spin_unlock(&oi->ip_lock);
return 0;
}
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 2cc5c99fe941..4af9a6dfddd2 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1348,14 +1348,15 @@ void ocfs2_refresh_inode(struct inode *inode,
inode->i_blocks = 0;
else
inode->i_blocks = ocfs2_inode_sector_count(inode);
+
+ spin_unlock(&OCFS2_I(inode)->ip_lock);
+
inode_set_atime(inode, le64_to_cpu(fe->i_atime),
le32_to_cpu(fe->i_atime_nsec));
inode_set_mtime(inode, le64_to_cpu(fe->i_mtime),
le32_to_cpu(fe->i_mtime_nsec));
inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
le32_to_cpu(fe->i_ctime_nsec));
-
- spin_unlock(&OCFS2_I(inode)->ip_lock);
}
int ocfs2_validate_inode_block(struct super_block *sb,
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index c4a4016d3866..b29f71357d63 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -153,8 +153,8 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle,
spin_lock(&OCFS2_I(bm_inode)->ip_lock);
OCFS2_I(bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
- le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits);
spin_unlock(&OCFS2_I(bm_inode)->ip_lock);
+ le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits);
i_size_write(bm_inode, le64_to_cpu(fe->i_size));
ocfs2_journal_dirty(handle, bm_bh);
@@ -564,8 +564,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
spin_lock(&OCFS2_I(main_bm_inode)->ip_lock);
OCFS2_I(main_bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
- le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits);
spin_unlock(&OCFS2_I(main_bm_inode)->ip_lock);
+ le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits);
i_size_write(main_bm_inode, le64_to_cpu(fe->i_size));
ocfs2_update_super_and_backups(main_bm_inode, input->clusters);
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 9e847f59c9ef..3f91615d8702 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -798,9 +798,9 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
spin_lock(&OCFS2_I(alloc_inode)->ip_lock);
OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
+ spin_unlock(&OCFS2_I(alloc_inode)->ip_lock);
fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb,
le32_to_cpu(fe->i_clusters)));
- spin_unlock(&OCFS2_I(alloc_inode)->ip_lock);
i_size_write(alloc_inode, le64_to_cpu(fe->i_size));
alloc_inode->i_blocks = ocfs2_inode_sector_count(alloc_inode);
ocfs2_update_inode_fsync_trans(handle, alloc_inode, 0);
--
2.35.3
This is a standalone cleanup, so please send in a separate thread. Thanks, Joseph On 9/8/24 10:07 PM, Heming Zhao wrote: > Some of the spinlock_t ip_lock protection scopes are incorrect and > should follow the usage in 'struct ocfs2_inode_info'. > > Signed-off-by: Heming Zhao <heming.zhao@suse.com> > Reviewed-by: Su Yue <glass.su@suse.com> > --- > fs/ocfs2/dlmglue.c | 3 ++- > fs/ocfs2/inode.c | 5 +++-- > fs/ocfs2/resize.c | 4 ++-- > fs/ocfs2/suballoc.c | 2 +- > 4 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c > index da78a04d6f0b..4a5900c8dc8f 100644 > --- a/fs/ocfs2/dlmglue.c > +++ b/fs/ocfs2/dlmglue.c > @@ -2232,6 +2232,8 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode) > else > inode->i_blocks = ocfs2_inode_sector_count(inode); > > + spin_unlock(&oi->ip_lock); > + > i_uid_write(inode, be32_to_cpu(lvb->lvb_iuid)); > i_gid_write(inode, be32_to_cpu(lvb->lvb_igid)); > inode->i_mode = be16_to_cpu(lvb->lvb_imode); > @@ -2242,7 +2244,6 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode) > inode_set_mtime_to_ts(inode, ts); > ocfs2_unpack_timespec(&ts, be64_to_cpu(lvb->lvb_ictime_packed)); > inode_set_ctime_to_ts(inode, ts); > - spin_unlock(&oi->ip_lock); > return 0; > } > > diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c > index 2cc5c99fe941..4af9a6dfddd2 100644 > --- a/fs/ocfs2/inode.c > +++ b/fs/ocfs2/inode.c > @@ -1348,14 +1348,15 @@ void ocfs2_refresh_inode(struct inode *inode, > inode->i_blocks = 0; > else > inode->i_blocks = ocfs2_inode_sector_count(inode); > + > + spin_unlock(&OCFS2_I(inode)->ip_lock); > + > inode_set_atime(inode, le64_to_cpu(fe->i_atime), > le32_to_cpu(fe->i_atime_nsec)); > inode_set_mtime(inode, le64_to_cpu(fe->i_mtime), > le32_to_cpu(fe->i_mtime_nsec)); > inode_set_ctime(inode, le64_to_cpu(fe->i_ctime), > le32_to_cpu(fe->i_ctime_nsec)); > - > - spin_unlock(&OCFS2_I(inode)->ip_lock); > } > > int ocfs2_validate_inode_block(struct super_block *sb, > diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c > index c4a4016d3866..b29f71357d63 100644 > --- a/fs/ocfs2/resize.c > +++ b/fs/ocfs2/resize.c > @@ -153,8 +153,8 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle, > > spin_lock(&OCFS2_I(bm_inode)->ip_lock); > OCFS2_I(bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters); > - le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits); > spin_unlock(&OCFS2_I(bm_inode)->ip_lock); > + le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits); > i_size_write(bm_inode, le64_to_cpu(fe->i_size)); > > ocfs2_journal_dirty(handle, bm_bh); > @@ -564,8 +564,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) > > spin_lock(&OCFS2_I(main_bm_inode)->ip_lock); > OCFS2_I(main_bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters); > - le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits); > spin_unlock(&OCFS2_I(main_bm_inode)->ip_lock); > + le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits); > i_size_write(main_bm_inode, le64_to_cpu(fe->i_size)); > > ocfs2_update_super_and_backups(main_bm_inode, input->clusters); > diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c > index 9e847f59c9ef..3f91615d8702 100644 > --- a/fs/ocfs2/suballoc.c > +++ b/fs/ocfs2/suballoc.c > @@ -798,9 +798,9 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, > > spin_lock(&OCFS2_I(alloc_inode)->ip_lock); > OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters); > + spin_unlock(&OCFS2_I(alloc_inode)->ip_lock); > fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb, > le32_to_cpu(fe->i_clusters))); > - spin_unlock(&OCFS2_I(alloc_inode)->ip_lock); > i_size_write(alloc_inode, le64_to_cpu(fe->i_size)); > alloc_inode->i_blocks = ocfs2_inode_sector_count(alloc_inode); > ocfs2_update_inode_fsync_trans(handle, alloc_inode, 0);
On 10/8/24 15:18, Joseph Qi wrote: > This is a standalone cleanup, so please send in a separate thread. > > Thanks, > Joseph No problem. -Heming > > On 9/8/24 10:07 PM, Heming Zhao wrote: >> Some of the spinlock_t ip_lock protection scopes are incorrect and >> should follow the usage in 'struct ocfs2_inode_info'. >> >> Signed-off-by: Heming Zhao <heming.zhao@suse.com> >> Reviewed-by: Su Yue <glass.su@suse.com> >> --- >> fs/ocfs2/dlmglue.c | 3 ++- >> fs/ocfs2/inode.c | 5 +++-- >> fs/ocfs2/resize.c | 4 ++-- >> fs/ocfs2/suballoc.c | 2 +- >> 4 files changed, 8 insertions(+), 6 deletions(-) >> >> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c >> index da78a04d6f0b..4a5900c8dc8f 100644 >> --- a/fs/ocfs2/dlmglue.c >> +++ b/fs/ocfs2/dlmglue.c >> @@ -2232,6 +2232,8 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode) >> else >> inode->i_blocks = ocfs2_inode_sector_count(inode); >> ... ...
© 2016 - 2024 Red Hat, Inc.