Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gfs2: Move gfs2_dinode_dealloc

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>

+69 -68
+68
fs/gfs2/inode.c
··· 439 439 return error; 440 440 } 441 441 442 + static void gfs2_final_release_pages(struct gfs2_inode *ip) 443 + { 444 + struct inode *inode = &ip->i_inode; 445 + struct gfs2_glock *gl = ip->i_gl; 446 + 447 + if (unlikely(!gl)) { 448 + /* This can only happen during incomplete inode creation. */ 449 + BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); 450 + return; 451 + } 452 + 453 + truncate_inode_pages(gfs2_glock2aspace(gl), 0); 454 + truncate_inode_pages(&inode->i_data, 0); 455 + 456 + if (atomic_read(&gl->gl_revokes) == 0) { 457 + clear_bit(GLF_LFLUSH, &gl->gl_flags); 458 + clear_bit(GLF_DIRTY, &gl->gl_flags); 459 + } 460 + } 461 + 462 + int gfs2_dinode_dealloc(struct gfs2_inode *ip) 463 + { 464 + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 465 + struct gfs2_rgrpd *rgd; 466 + struct gfs2_holder gh; 467 + int error; 468 + 469 + if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { 470 + gfs2_consist_inode(ip); 471 + return -EIO; 472 + } 473 + 474 + gfs2_rindex_update(sdp); 475 + 476 + error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); 477 + if (error) 478 + return error; 479 + 480 + rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1); 481 + if (!rgd) { 482 + gfs2_consist_inode(ip); 483 + error = -EIO; 484 + goto out_qs; 485 + } 486 + 487 + error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 488 + LM_FLAG_NODE_SCOPE, &gh); 489 + if (error) 490 + goto out_qs; 491 + 492 + error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 493 + sdp->sd_jdesc->jd_blocks); 494 + if (error) 495 + goto out_rg_gunlock; 496 + 497 + gfs2_free_di(rgd, ip); 498 + 499 + gfs2_final_release_pages(ip); 500 + 501 + gfs2_trans_end(sdp); 502 + 503 + out_rg_gunlock: 504 + gfs2_glock_dq_uninit(&gh); 505 + out_qs: 506 + gfs2_quota_unhold(ip); 507 + return error; 508 + } 509 + 442 510 static void gfs2_init_dir(struct buffer_head *dibh, 443 511 const struct gfs2_inode *parent) 444 512 {
+1
fs/gfs2/inode.h
··· 92 92 struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, 93 93 u64 no_formal_ino, 94 94 unsigned int blktype); 95 + int gfs2_dinode_dealloc(struct gfs2_inode *ip); 95 96 96 97 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 97 98 int is_root);
-68
fs/gfs2/super.c
··· 1173 1173 return 0; 1174 1174 } 1175 1175 1176 - static void gfs2_final_release_pages(struct gfs2_inode *ip) 1177 - { 1178 - struct inode *inode = &ip->i_inode; 1179 - struct gfs2_glock *gl = ip->i_gl; 1180 - 1181 - if (unlikely(!gl)) { 1182 - /* This can only happen during incomplete inode creation. */ 1183 - BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); 1184 - return; 1185 - } 1186 - 1187 - truncate_inode_pages(gfs2_glock2aspace(gl), 0); 1188 - truncate_inode_pages(&inode->i_data, 0); 1189 - 1190 - if (atomic_read(&gl->gl_revokes) == 0) { 1191 - clear_bit(GLF_LFLUSH, &gl->gl_flags); 1192 - clear_bit(GLF_DIRTY, &gl->gl_flags); 1193 - } 1194 - } 1195 - 1196 - static int gfs2_dinode_dealloc(struct gfs2_inode *ip) 1197 - { 1198 - struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1199 - struct gfs2_rgrpd *rgd; 1200 - struct gfs2_holder gh; 1201 - int error; 1202 - 1203 - if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { 1204 - gfs2_consist_inode(ip); 1205 - return -EIO; 1206 - } 1207 - 1208 - gfs2_rindex_update(sdp); 1209 - 1210 - error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); 1211 - if (error) 1212 - return error; 1213 - 1214 - rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1); 1215 - if (!rgd) { 1216 - gfs2_consist_inode(ip); 1217 - error = -EIO; 1218 - goto out_qs; 1219 - } 1220 - 1221 - error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 1222 - LM_FLAG_NODE_SCOPE, &gh); 1223 - if (error) 1224 - goto out_qs; 1225 - 1226 - error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 1227 - sdp->sd_jdesc->jd_blocks); 1228 - if (error) 1229 - goto out_rg_gunlock; 1230 - 1231 - gfs2_free_di(rgd, ip); 1232 - 1233 - gfs2_final_release_pages(ip); 1234 - 1235 - gfs2_trans_end(sdp); 1236 - 1237 - out_rg_gunlock: 1238 - gfs2_glock_dq_uninit(&gh); 1239 - out_qs: 1240 - gfs2_quota_unhold(ip); 1241 - return error; 1242 - } 1243 - 1244 1176 /** 1245 1177 * gfs2_glock_put_eventually 1246 1178 * @gl: The glock to put