diff options
| -rw-r--r-- | fs/gfs2/inode.c | 88 | ||||
| -rw-r--r-- | fs/gfs2/inode.h | 1 |
2 files changed, 44 insertions, 45 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 58c2ce785fed..260316954ad7 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
| @@ -280,6 +280,50 @@ out: | |||
| 280 | return error; | 280 | return error; |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | static int gfs2_change_nlink_i(struct gfs2_inode *ip) | ||
| 284 | { | ||
| 285 | struct gfs2_sbd *sdp = ip->i_inode.i_sb->s_fs_info; | ||
| 286 | struct gfs2_inode *rindex = GFS2_I(sdp->sd_rindex); | ||
| 287 | struct gfs2_glock *ri_gl = rindex->i_gl; | ||
| 288 | struct gfs2_rgrpd *rgd; | ||
| 289 | struct gfs2_holder ri_gh, rg_gh; | ||
| 290 | int existing, error; | ||
| 291 | |||
| 292 | /* if we come from rename path, we could have the lock already */ | ||
| 293 | existing = gfs2_glock_is_locked_by_me(ri_gl); | ||
| 294 | if (!existing) { | ||
| 295 | error = gfs2_rindex_hold(sdp, &ri_gh); | ||
| 296 | if (error) | ||
| 297 | goto out; | ||
| 298 | } | ||
| 299 | |||
| 300 | /* find the matching rgd */ | ||
| 301 | error = -EIO; | ||
| 302 | rgd = gfs2_blk2rgrpd(sdp, ip->i_num.no_addr); | ||
| 303 | if (!rgd) | ||
| 304 | goto out_norgrp; | ||
| 305 | |||
| 306 | /* | ||
| 307 | * Eventually we may want to move rgd(s) to a linked list | ||
| 308 | * and piggyback the free logic into one of gfs2 daemons | ||
| 309 | * to gain some performance. | ||
| 310 | */ | ||
| 311 | if (!rgd->rd_gl || !gfs2_glock_is_locked_by_me(rgd->rd_gl)) { | ||
| 312 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &rg_gh); | ||
| 313 | if (error) | ||
| 314 | goto out_norgrp; | ||
| 315 | |||
| 316 | gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ | ||
| 317 | gfs2_glock_dq_uninit(&rg_gh); | ||
| 318 | } | ||
| 319 | |||
| 320 | out_norgrp: | ||
| 321 | if (!existing) | ||
| 322 | gfs2_glock_dq_uninit(&ri_gh); | ||
| 323 | out: | ||
| 324 | return error; | ||
| 325 | } | ||
| 326 | |||
| 283 | /** | 327 | /** |
| 284 | * gfs2_change_nlink - Change nlink count on inode | 328 | * gfs2_change_nlink - Change nlink count on inode |
| 285 | * @ip: The GFS2 inode | 329 | * @ip: The GFS2 inode |
| @@ -326,50 +370,6 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) | |||
| 326 | return error; | 370 | return error; |
| 327 | } | 371 | } |
| 328 | 372 | ||
| 329 | int gfs2_change_nlink_i(struct gfs2_inode *ip) | ||
| 330 | { | ||
| 331 | struct gfs2_sbd *sdp = ip->i_inode.i_sb->s_fs_info; | ||
| 332 | struct gfs2_inode *rindex = GFS2_I(sdp->sd_rindex); | ||
| 333 | struct gfs2_glock *ri_gl = rindex->i_gl; | ||
| 334 | struct gfs2_rgrpd *rgd; | ||
| 335 | struct gfs2_holder ri_gh, rg_gh; | ||
| 336 | int existing, error; | ||
| 337 | |||
| 338 | /* if we come from rename path, we could have the lock already */ | ||
| 339 | existing = gfs2_glock_is_locked_by_me(ri_gl); | ||
| 340 | if (!existing) { | ||
| 341 | error = gfs2_rindex_hold(sdp, &ri_gh); | ||
| 342 | if (error) | ||
| 343 | goto out; | ||
| 344 | } | ||
| 345 | |||
| 346 | /* find the matching rgd */ | ||
| 347 | error = -EIO; | ||
| 348 | rgd = gfs2_blk2rgrpd(sdp, ip->i_num.no_addr); | ||
| 349 | if (!rgd) | ||
| 350 | goto out_norgrp; | ||
| 351 | |||
| 352 | /* | ||
| 353 | * Eventually we may want to move rgd(s) to a linked list | ||
| 354 | * and piggyback the free logic into one of gfs2 daemons | ||
| 355 | * to gain some performance. | ||
| 356 | */ | ||
| 357 | if (!rgd->rd_gl || !gfs2_glock_is_locked_by_me(rgd->rd_gl)) { | ||
| 358 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &rg_gh); | ||
| 359 | if (error) | ||
| 360 | goto out_norgrp; | ||
| 361 | |||
| 362 | gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ | ||
| 363 | gfs2_glock_dq_uninit(&rg_gh); | ||
| 364 | } | ||
| 365 | |||
| 366 | out_norgrp: | ||
| 367 | if (!existing) | ||
| 368 | gfs2_glock_dq_uninit(&ri_gh); | ||
| 369 | out: | ||
| 370 | return error; | ||
| 371 | } | ||
| 372 | |||
| 373 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) | 373 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) |
| 374 | { | 374 | { |
| 375 | struct qstr qstr; | 375 | struct qstr qstr; |
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index cee281b5326b..b57f448b15bc 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
| @@ -40,7 +40,6 @@ int gfs2_inode_refresh(struct gfs2_inode *ip); | |||
| 40 | 40 | ||
| 41 | int gfs2_dinode_dealloc(struct gfs2_inode *inode); | 41 | int gfs2_dinode_dealloc(struct gfs2_inode *inode); |
| 42 | int gfs2_change_nlink(struct gfs2_inode *ip, int diff); | 42 | int gfs2_change_nlink(struct gfs2_inode *ip, int diff); |
| 43 | int gfs2_change_nlink_i(struct gfs2_inode *ip); | ||
| 44 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | 43 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, |
| 45 | int is_root, struct nameidata *nd); | 44 | int is_root, struct nameidata *nd); |
| 46 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | 45 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, |
