Skip to content

Commit c894275

Browse files
author
Andreas Gruenbacher
committed
gfs2: Move gfs2_dinode_dealloc
JIRA: https://issues.redhat.com/browse/RHEL-88093 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git Move gfs2_dinode_dealloc() and its helper gfs2_final_release_pages() from super.c to inode.c. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> (cherry picked from commit 1deedbb0cd93da9364219c287a35d819e7624b78)
1 parent ba37a31 commit c894275

File tree

3 files changed

+69
-68
lines changed

3 files changed

+69
-68
lines changed

fs/gfs2/inode.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,74 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks)
431431
return error;
432432
}
433433

434+
static void gfs2_final_release_pages(struct gfs2_inode *ip)
435+
{
436+
struct inode *inode = &ip->i_inode;
437+
struct gfs2_glock *gl = ip->i_gl;
438+
439+
if (unlikely(!gl)) {
440+
/* This can only happen during incomplete inode creation. */
441+
BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags));
442+
return;
443+
}
444+
445+
truncate_inode_pages(gfs2_glock2aspace(gl), 0);
446+
truncate_inode_pages(&inode->i_data, 0);
447+
448+
if (atomic_read(&gl->gl_revokes) == 0) {
449+
clear_bit(GLF_LFLUSH, &gl->gl_flags);
450+
clear_bit(GLF_DIRTY, &gl->gl_flags);
451+
}
452+
}
453+
454+
int gfs2_dinode_dealloc(struct gfs2_inode *ip)
455+
{
456+
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
457+
struct gfs2_rgrpd *rgd;
458+
struct gfs2_holder gh;
459+
int error;
460+
461+
if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
462+
gfs2_consist_inode(ip);
463+
return -EIO;
464+
}
465+
466+
gfs2_rindex_update(sdp);
467+
468+
error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
469+
if (error)
470+
return error;
471+
472+
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
473+
if (!rgd) {
474+
gfs2_consist_inode(ip);
475+
error = -EIO;
476+
goto out_qs;
477+
}
478+
479+
error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
480+
LM_FLAG_NODE_SCOPE, &gh);
481+
if (error)
482+
goto out_qs;
483+
484+
error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
485+
sdp->sd_jdesc->jd_blocks);
486+
if (error)
487+
goto out_rg_gunlock;
488+
489+
gfs2_free_di(rgd, ip);
490+
491+
gfs2_final_release_pages(ip);
492+
493+
gfs2_trans_end(sdp);
494+
495+
out_rg_gunlock:
496+
gfs2_glock_dq_uninit(&gh);
497+
out_qs:
498+
gfs2_quota_unhold(ip);
499+
return error;
500+
}
501+
434502
static void gfs2_init_dir(struct buffer_head *dibh,
435503
const struct gfs2_inode *parent)
436504
{

fs/gfs2/inode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
9494
struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
9595
u64 no_formal_ino,
9696
unsigned int blktype);
97+
int gfs2_dinode_dealloc(struct gfs2_inode *ip);
9798

9899
int gfs2_inode_refresh(struct gfs2_inode *ip);
99100

fs/gfs2/super.c

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,74 +1187,6 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root)
11871187
return 0;
11881188
}
11891189

1190-
static void gfs2_final_release_pages(struct gfs2_inode *ip)
1191-
{
1192-
struct inode *inode = &ip->i_inode;
1193-
struct gfs2_glock *gl = ip->i_gl;
1194-
1195-
if (unlikely(!gl)) {
1196-
/* This can only happen during incomplete inode creation. */
1197-
BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags));
1198-
return;
1199-
}
1200-
1201-
truncate_inode_pages(gfs2_glock2aspace(gl), 0);
1202-
truncate_inode_pages(&inode->i_data, 0);
1203-
1204-
if (atomic_read(&gl->gl_revokes) == 0) {
1205-
clear_bit(GLF_LFLUSH, &gl->gl_flags);
1206-
clear_bit(GLF_DIRTY, &gl->gl_flags);
1207-
}
1208-
}
1209-
1210-
static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
1211-
{
1212-
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1213-
struct gfs2_rgrpd *rgd;
1214-
struct gfs2_holder gh;
1215-
int error;
1216-
1217-
if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
1218-
gfs2_consist_inode(ip);
1219-
return -EIO;
1220-
}
1221-
1222-
gfs2_rindex_update(sdp);
1223-
1224-
error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
1225-
if (error)
1226-
return error;
1227-
1228-
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
1229-
if (!rgd) {
1230-
gfs2_consist_inode(ip);
1231-
error = -EIO;
1232-
goto out_qs;
1233-
}
1234-
1235-
error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
1236-
LM_FLAG_NODE_SCOPE, &gh);
1237-
if (error)
1238-
goto out_qs;
1239-
1240-
error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
1241-
sdp->sd_jdesc->jd_blocks);
1242-
if (error)
1243-
goto out_rg_gunlock;
1244-
1245-
gfs2_free_di(rgd, ip);
1246-
1247-
gfs2_final_release_pages(ip);
1248-
1249-
gfs2_trans_end(sdp);
1250-
1251-
out_rg_gunlock:
1252-
gfs2_glock_dq_uninit(&gh);
1253-
out_qs:
1254-
gfs2_quota_unhold(ip);
1255-
return error;
1256-
}
1257-
12581190
/**
12591191
* gfs2_glock_put_eventually
12601192
* @gl: The glock to put

0 commit comments

Comments
 (0)