Skip to content

Commit f286d62

Browse files
committed
gfs2: Keep track of deleted inode generations in LVBs
When deleting an inode, keep track of the generation of the deleted inode in the inode glock Lock Value Block (LVB). When trying to delete an inode remotely, check the last-known inode generation against the deleted inode generation to skip duplicate remote deletes. This avoids taking the resource group glock in order to verify the block type. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 15f2547 commit f286d62

5 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎fs/gfs2/glock.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,25 @@ __acquires(&gl->gl_lockref.lock)
755755
return;
756756
}
757757

758+
void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation)
759+
{
760+
struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr;
761+
762+
if (ri->ri_magic == 0)
763+
ri->ri_magic = cpu_to_be32(GFS2_MAGIC);
764+
if (ri->ri_magic == cpu_to_be32(GFS2_MAGIC))
765+
ri->ri_generation_deleted = cpu_to_be64(generation);
766+
}
767+
768+
bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation)
769+
{
770+
struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr;
771+
772+
if (ri->ri_magic != cpu_to_be32(GFS2_MAGIC))
773+
return false;
774+
return generation <= be64_to_cpu(ri->ri_generation_deleted);
775+
}
776+
758777
static void delete_work_func(struct work_struct *work)
759778
{
760779
struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_delete);

‎fs/gfs2/glock.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,7 @@ static inline void glock_clear_object(struct gfs2_glock *gl, void *object)
306306
spin_unlock(&gl->gl_lockref.lock);
307307
}
308308

309+
extern void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation);
310+
extern bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation);
311+
309312
#endif /* __GLOCK_DOT_H__ */

‎fs/gfs2/glops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ const struct gfs2_glock_operations gfs2_inode_glops = {
692692
.go_lock = inode_go_lock,
693693
.go_dump = inode_go_dump,
694694
.go_type = LM_TYPE_INODE,
695-
.go_flags = GLOF_ASPACE | GLOF_LRU,
695+
.go_flags = GLOF_ASPACE | GLOF_LRU | GLOF_LVB,
696696
.go_free = inode_go_free,
697697
};
698698

‎fs/gfs2/super.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,8 @@ static void gfs2_evict_inode(struct inode *inode)
13151315
goto out;
13161316
}
13171317

1318+
if (gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino))
1319+
goto out_truncate;
13181320
error = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
13191321
if (error)
13201322
goto out_truncate;
@@ -1368,6 +1370,7 @@ static void gfs2_evict_inode(struct inode *inode)
13681370
that subsequent inode creates don't see an old gl_object. */
13691371
glock_clear_object(ip->i_gl, ip);
13701372
error = gfs2_dinode_dealloc(ip);
1373+
gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
13711374
goto out_unlock;
13721375

13731376
out_truncate:

‎include/uapi/linux/gfs2_ondisk.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ struct gfs2_rindex {
171171
#define GFS2_RGF_NOALLOC 0x00000008
172172
#define GFS2_RGF_TRIMMED 0x00000010
173173

174+
struct gfs2_inode_lvb {
175+
__be32 ri_magic;
176+
__be32 __pad;
177+
__be64 ri_generation_deleted;
178+
};
179+
174180
struct gfs2_rgrp_lvb {
175181
__be32 rl_magic;
176182
__be32 rl_flags;

0 commit comments

Comments
 (0)