Message ID | 20240729080454.12771-4-heming.zhao@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | give ocfs2 the ability to reclaim suballocator free bg | expand |
On 2024/7/29 16:04, 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> LGTM: 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 cb40cafbc062..28ab6578f957 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 dc421f55ed8f..e2569b0d6204 100644 > --- a/fs/ocfs2/suballoc.c > +++ b/fs/ocfs2/suballoc.c > @@ -790,9 +790,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);
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index cb40cafbc062..28ab6578f957 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 dc421f55ed8f..e2569b0d6204 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -790,9 +790,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);
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> --- 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(-)