@@ -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+
434502static void gfs2_init_dir (struct buffer_head * dibh ,
435503 const struct gfs2_inode * parent )
436504{
0 commit comments