aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/lops.c6
-rw-r--r--fs/gfs2/mount.c25
-rw-r--r--fs/gfs2/ops_address.c3
-rw-r--r--fs/gfs2/ops_file.c29
-rw-r--r--fs/gfs2/rgrp.c16
5 files changed, 47 insertions, 32 deletions
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index aff70f0698fd..3b395c41b2f3 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -486,8 +486,8 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
486 gfs2_pin(sdp, bd->bd_bh); 486 gfs2_pin(sdp, bd->bd_bh);
487 tr->tr_num_databuf_new++; 487 tr->tr_num_databuf_new++;
488 } 488 }
489 sdp->sd_log_num_databuf++;
490 gfs2_log_lock(sdp); 489 gfs2_log_lock(sdp);
490 sdp->sd_log_num_databuf++;
491 list_add(&le->le_list, &sdp->sd_log_le_databuf); 491 list_add(&le->le_list, &sdp->sd_log_le_databuf);
492 gfs2_log_unlock(sdp); 492 gfs2_log_unlock(sdp);
493} 493}
@@ -523,7 +523,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
523 struct buffer_head *bh = NULL,*bh1 = NULL; 523 struct buffer_head *bh = NULL,*bh1 = NULL;
524 struct gfs2_log_descriptor *ld; 524 struct gfs2_log_descriptor *ld;
525 unsigned int limit; 525 unsigned int limit;
526 unsigned int total_dbuf = sdp->sd_log_num_databuf; 526 unsigned int total_dbuf;
527 unsigned int total_jdata = sdp->sd_log_num_jdata; 527 unsigned int total_jdata = sdp->sd_log_num_jdata;
528 unsigned int num, n; 528 unsigned int num, n;
529 __be64 *ptr = NULL; 529 __be64 *ptr = NULL;
@@ -535,6 +535,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
535 * into the log along with a header 535 * into the log along with a header
536 */ 536 */
537 gfs2_log_lock(sdp); 537 gfs2_log_lock(sdp);
538 total_dbuf = sdp->sd_log_num_databuf;
538 bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, 539 bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf,
539 bd_le.le_list); 540 bd_le.le_list);
540 while(total_dbuf) { 541 while(total_dbuf) {
@@ -653,6 +654,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
653 break; 654 break;
654 } 655 }
655 bh = NULL; 656 bh = NULL;
657 BUG_ON(total_dbuf < num);
656 total_dbuf -= num; 658 total_dbuf -= num;
657 total_jdata -= num; 659 total_jdata -= num;
658 } 660 }
diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c
index 6f006a804db3..4864659555d4 100644
--- a/fs/gfs2/mount.c
+++ b/fs/gfs2/mount.c
@@ -82,19 +82,20 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
82 char *options, *o, *v; 82 char *options, *o, *v;
83 int error = 0; 83 int error = 0;
84 84
85 /* If someone preloaded options, use those instead */ 85 if (!remount) {
86 spin_lock(&gfs2_sys_margs_lock); 86 /* If someone preloaded options, use those instead */
87 if (!remount && gfs2_sys_margs) { 87 spin_lock(&gfs2_sys_margs_lock);
88 data = gfs2_sys_margs; 88 if (gfs2_sys_margs) {
89 gfs2_sys_margs = NULL; 89 data = gfs2_sys_margs;
90 } 90 gfs2_sys_margs = NULL;
91 spin_unlock(&gfs2_sys_margs_lock); 91 }
92 spin_unlock(&gfs2_sys_margs_lock);
92 93
93 /* Set some defaults */ 94 /* Set some defaults */
94 memset(args, 0, sizeof(struct gfs2_args)); 95 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
95 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT; 96 args->ar_quota = GFS2_QUOTA_DEFAULT;
96 args->ar_quota = GFS2_QUOTA_DEFAULT; 97 args->ar_data = GFS2_DATA_DEFAULT;
97 args->ar_data = GFS2_DATA_DEFAULT; 98 }
98 99
99 /* Split the options into tokens with the "," character and 100 /* Split the options into tokens with the "," character and
100 process them */ 101 process them */
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index ce90032c010e..42a5f58f6fca 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -416,7 +416,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
416 416
417 error = gfs2_trans_begin(sdp, rblocks, 0); 417 error = gfs2_trans_begin(sdp, rblocks, 0);
418 if (error) 418 if (error)
419 goto out; 419 goto out_trans_fail;
420 420
421 if (gfs2_is_stuffed(ip)) { 421 if (gfs2_is_stuffed(ip)) {
422 if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) { 422 if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
@@ -434,6 +434,7 @@ prepare_write:
434out: 434out:
435 if (error) { 435 if (error) {
436 gfs2_trans_end(sdp); 436 gfs2_trans_end(sdp);
437out_trans_fail:
437 if (alloc_required) { 438 if (alloc_required) {
438 gfs2_inplace_release(ip); 439 gfs2_inplace_release(ip);
439out_qunlock: 440out_qunlock:
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 773421130116..94d76ace0b95 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -177,8 +177,8 @@ static const u32 fsflags_to_gfs2[32] = {
177 [5] = GFS2_DIF_APPENDONLY, 177 [5] = GFS2_DIF_APPENDONLY,
178 [7] = GFS2_DIF_NOATIME, 178 [7] = GFS2_DIF_NOATIME,
179 [12] = GFS2_DIF_EXHASH, 179 [12] = GFS2_DIF_EXHASH,
180 [14] = GFS2_DIF_JDATA, 180 [14] = GFS2_DIF_INHERIT_JDATA,
181 [20] = GFS2_DIF_DIRECTIO, 181 [20] = GFS2_DIF_INHERIT_DIRECTIO,
182}; 182};
183 183
184static const u32 gfs2_to_fsflags[32] = { 184static const u32 gfs2_to_fsflags[32] = {
@@ -187,8 +187,6 @@ static const u32 gfs2_to_fsflags[32] = {
187 [gfs2fl_AppendOnly] = FS_APPEND_FL, 187 [gfs2fl_AppendOnly] = FS_APPEND_FL,
188 [gfs2fl_NoAtime] = FS_NOATIME_FL, 188 [gfs2fl_NoAtime] = FS_NOATIME_FL,
189 [gfs2fl_ExHash] = FS_INDEX_FL, 189 [gfs2fl_ExHash] = FS_INDEX_FL,
190 [gfs2fl_Jdata] = FS_JOURNAL_DATA_FL,
191 [gfs2fl_Directio] = FS_DIRECTIO_FL,
192 [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL, 190 [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL,
193 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL, 191 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
194}; 192};
@@ -207,6 +205,12 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
207 return error; 205 return error;
208 206
209 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags); 207 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags);
208 if (!S_ISDIR(inode->i_mode)) {
209 if (ip->i_di.di_flags & GFS2_DIF_JDATA)
210 fsflags |= FS_JOURNAL_DATA_FL;
211 if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
212 fsflags |= FS_DIRECTIO_FL;
213 }
210 if (put_user(fsflags, ptr)) 214 if (put_user(fsflags, ptr))
211 error = -EFAULT; 215 error = -EFAULT;
212 216
@@ -270,13 +274,6 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
270 if ((new_flags ^ flags) == 0) 274 if ((new_flags ^ flags) == 0)
271 goto out; 275 goto out;
272 276
273 if (S_ISDIR(inode->i_mode)) {
274 if ((new_flags ^ flags) & GFS2_DIF_JDATA)
275 new_flags ^= (GFS2_DIF_JDATA|GFS2_DIF_INHERIT_JDATA);
276 if ((new_flags ^ flags) & GFS2_DIF_DIRECTIO)
277 new_flags ^= (GFS2_DIF_DIRECTIO|GFS2_DIF_INHERIT_DIRECTIO);
278 }
279
280 error = -EINVAL; 277 error = -EINVAL;
281 if ((new_flags ^ flags) & ~GFS2_FLAGS_USER_SET) 278 if ((new_flags ^ flags) & ~GFS2_FLAGS_USER_SET)
282 goto out; 279 goto out;
@@ -315,11 +312,19 @@ out:
315 312
316static int gfs2_set_flags(struct file *filp, u32 __user *ptr) 313static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
317{ 314{
315 struct inode *inode = filp->f_path.dentry->d_inode;
318 u32 fsflags, gfsflags; 316 u32 fsflags, gfsflags;
319 if (get_user(fsflags, ptr)) 317 if (get_user(fsflags, ptr))
320 return -EFAULT; 318 return -EFAULT;
321 gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags); 319 gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
322 return do_gfs2_set_flags(filp, gfsflags, ~0); 320 if (!S_ISDIR(inode->i_mode)) {
321 if (gfsflags & GFS2_DIF_INHERIT_JDATA)
322 gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA);
323 if (gfsflags & GFS2_DIF_INHERIT_DIRECTIO)
324 gfsflags ^= (GFS2_DIF_DIRECTIO | GFS2_DIF_INHERIT_DIRECTIO);
325 return do_gfs2_set_flags(filp, gfsflags, ~0);
326 }
327 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
323} 328}
324 329
325static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 330static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index e4e040625153..ce48c4594ec8 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -863,16 +863,19 @@ static struct inode *try_rgrp_unlink(struct gfs2_rgrpd *rgd, u64 *last_unlinked)
863 u64 no_addr; 863 u64 no_addr;
864 864
865 for(;;) { 865 for(;;) {
866 if (goal >= rgd->rd_data)
867 break;
866 goal = rgblk_search(rgd, goal, GFS2_BLKST_UNLINKED, 868 goal = rgblk_search(rgd, goal, GFS2_BLKST_UNLINKED,
867 GFS2_BLKST_UNLINKED); 869 GFS2_BLKST_UNLINKED);
868 if (goal == 0) 870 if (goal == BFITNOENT)
869 return 0; 871 break;
870 no_addr = goal + rgd->rd_data0; 872 no_addr = goal + rgd->rd_data0;
871 if (no_addr <= *last_unlinked) 873 goal++;
874 if (no_addr < *last_unlinked)
872 continue; 875 continue;
873 *last_unlinked = no_addr; 876 *last_unlinked = no_addr;
874 inode = gfs2_inode_lookup(rgd->rd_sbd->sd_vfs, DT_UNKNOWN, 877 inode = gfs2_inode_lookup(rgd->rd_sbd->sd_vfs, DT_UNKNOWN,
875 no_addr, -1); 878 no_addr, -1);
876 if (!IS_ERR(inode)) 879 if (!IS_ERR(inode))
877 return inode; 880 return inode;
878 } 881 }
@@ -1313,7 +1316,7 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal,
1313 bi->bi_len, blk, new_state); 1316 bi->bi_len, blk, new_state);
1314 } 1317 }
1315 1318
1316 return (blk == BFITNOENT) ? 0 : (bi->bi_start * GFS2_NBBY) + blk; 1319 return (blk == BFITNOENT) ? blk : (bi->bi_start * GFS2_NBBY) + blk;
1317} 1320}
1318 1321
1319/** 1322/**
@@ -1393,6 +1396,7 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip)
1393 goal = rgd->rd_last_alloc_data; 1396 goal = rgd->rd_last_alloc_data;
1394 1397
1395 blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); 1398 blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED);
1399 BUG_ON(blk == BFITNOENT);
1396 rgd->rd_last_alloc_data = blk; 1400 rgd->rd_last_alloc_data = blk;
1397 1401
1398 block = rgd->rd_data0 + blk; 1402 block = rgd->rd_data0 + blk;
@@ -1437,6 +1441,7 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
1437 goal = rgd->rd_last_alloc_meta; 1441 goal = rgd->rd_last_alloc_meta;
1438 1442
1439 blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); 1443 blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED);
1444 BUG_ON(blk == BFITNOENT);
1440 rgd->rd_last_alloc_meta = blk; 1445 rgd->rd_last_alloc_meta = blk;
1441 1446
1442 block = rgd->rd_data0 + blk; 1447 block = rgd->rd_data0 + blk;
@@ -1478,6 +1483,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation)
1478 1483
1479 blk = rgblk_search(rgd, rgd->rd_last_alloc_meta, 1484 blk = rgblk_search(rgd, rgd->rd_last_alloc_meta,
1480 GFS2_BLKST_FREE, GFS2_BLKST_DINODE); 1485 GFS2_BLKST_FREE, GFS2_BLKST_DINODE);
1486 BUG_ON(blk == BFITNOENT);
1481 1487
1482 rgd->rd_last_alloc_meta = blk; 1488 rgd->rd_last_alloc_meta = blk;
1483 1489