Skip to content

Commit 801b036

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw
Pull GFS2 updates from Steven Whitehouse. * git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw: GFS2: Eliminate 64-bit divides GFS2: Reduce file fragmentation GFS2: kernel panic with small gfs2 filesystems - 1 RG GFS2: Fixing double brelse'ing bh allocated in gfs2_meta_read when EIO occurs GFS2: Combine functions get_local_rgrp and gfs2_inplace_reserve GFS2: Add kobject release method GFS2: Size seq_file buffer more carefully GFS2: Use seq_vprintf for glocks debugfs file seq_file: Add seq_vprintf function and export it GFS2: Use lvbs for storing rgrp information with mount option GFS2: Cache last hash bucket for glock seq_files GFS2: Increase buffer size for glocks and glstats debugfs files GFS2: Fix error handling when reading an invalid block from the journal GFS2: Add "top dir" flag support GFS2: Fold quota data into the reservations struct GFS2: Extend the life of the reservations
2 parents 614a6d4 + 15e1c96 commit 801b036

23 files changed

Lines changed: 1121 additions & 371 deletions

‎fs/gfs2/aops.c‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
614614
unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
615615
int alloc_required;
616616
int error = 0;
617-
struct gfs2_qadata *qa = NULL;
618617
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
619618
unsigned from = pos & (PAGE_CACHE_SIZE - 1);
620619
struct page *page;
@@ -638,15 +637,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
638637
gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
639638

640639
if (alloc_required) {
641-
qa = gfs2_qadata_get(ip);
642-
if (!qa) {
643-
error = -ENOMEM;
644-
goto out_unlock;
645-
}
646-
647640
error = gfs2_quota_lock_check(ip);
648641
if (error)
649-
goto out_alloc_put;
642+
goto out_unlock;
650643

651644
error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
652645
if (error)
@@ -708,8 +701,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
708701
gfs2_inplace_release(ip);
709702
out_qunlock:
710703
gfs2_quota_unlock(ip);
711-
out_alloc_put:
712-
gfs2_qadata_put(ip);
713704
}
714705
out_unlock:
715706
if (&ip->i_inode == sdp->sd_rindex) {
@@ -846,7 +837,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
846837
struct gfs2_sbd *sdp = GFS2_SB(inode);
847838
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
848839
struct buffer_head *dibh;
849-
struct gfs2_qadata *qa = ip->i_qadata;
850840
unsigned int from = pos & (PAGE_CACHE_SIZE - 1);
851841
unsigned int to = from + len;
852842
int ret;
@@ -878,12 +868,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
878868
brelse(dibh);
879869
failed:
880870
gfs2_trans_end(sdp);
881-
if (ip->i_res)
871+
if (gfs2_mb_reserved(ip))
882872
gfs2_inplace_release(ip);
883-
if (qa) {
873+
if (ip->i_res->rs_qa_qd_num)
884874
gfs2_quota_unlock(ip);
885-
gfs2_qadata_put(ip);
886-
}
887875
if (inode == sdp->sd_rindex) {
888876
gfs2_glock_dq(&m_ip->i_gh);
889877
gfs2_holder_uninit(&m_ip->i_gh);

‎fs/gfs2/bmap.c‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
785785
if (error)
786786
goto out_rlist;
787787

788+
if (gfs2_rs_active(ip->i_res)) /* needs to be done with the rgrp glock held */
789+
gfs2_rs_deltree(ip->i_res);
790+
788791
error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
789792
RES_INDIRECT + RES_STATFS + RES_QUOTA,
790793
revokes);
@@ -1045,12 +1048,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
10451048
lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift;
10461049

10471050
find_metapath(sdp, lblock, &mp, ip->i_height);
1048-
if (!gfs2_qadata_get(ip))
1049-
return -ENOMEM;
1051+
error = gfs2_rindex_update(sdp);
1052+
if (error)
1053+
return error;
10501054

10511055
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
10521056
if (error)
1053-
goto out;
1057+
return error;
10541058

10551059
while (height--) {
10561060
struct strip_mine sm;
@@ -1064,8 +1068,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
10641068

10651069
gfs2_quota_unhold(ip);
10661070

1067-
out:
1068-
gfs2_qadata_put(ip);
10691071
return error;
10701072
}
10711073

@@ -1167,19 +1169,14 @@ static int do_grow(struct inode *inode, u64 size)
11671169
struct gfs2_inode *ip = GFS2_I(inode);
11681170
struct gfs2_sbd *sdp = GFS2_SB(inode);
11691171
struct buffer_head *dibh;
1170-
struct gfs2_qadata *qa = NULL;
11711172
int error;
11721173
int unstuff = 0;
11731174

11741175
if (gfs2_is_stuffed(ip) &&
11751176
(size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) {
1176-
qa = gfs2_qadata_get(ip);
1177-
if (qa == NULL)
1178-
return -ENOMEM;
1179-
11801177
error = gfs2_quota_lock_check(ip);
11811178
if (error)
1182-
goto do_grow_alloc_put;
1179+
return error;
11831180

11841181
error = gfs2_inplace_reserve(ip, 1);
11851182
if (error)
@@ -1214,8 +1211,6 @@ static int do_grow(struct inode *inode, u64 size)
12141211
gfs2_inplace_release(ip);
12151212
do_grow_qunlock:
12161213
gfs2_quota_unlock(ip);
1217-
do_grow_alloc_put:
1218-
gfs2_qadata_put(ip);
12191214
}
12201215
return error;
12211216
}

‎fs/gfs2/dir.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
18541854
if (!ht)
18551855
return -ENOMEM;
18561856

1857-
if (!gfs2_qadata_get(dip)) {
1858-
error = -ENOMEM;
1859-
goto out;
1860-
}
1861-
18621857
error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
18631858
if (error)
1864-
goto out_put;
1859+
goto out;
18651860

18661861
/* Count the number of leaves */
18671862
bh = leaf_bh;
@@ -1942,8 +1937,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
19421937
out_rlist:
19431938
gfs2_rlist_free(&rlist);
19441939
gfs2_quota_unhold(dip);
1945-
out_put:
1946-
gfs2_qadata_put(dip);
19471940
out:
19481941
kfree(ht);
19491942
return error;

‎fs/gfs2/file.c‎

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static const u32 fsflags_to_gfs2[32] = {
142142
[7] = GFS2_DIF_NOATIME,
143143
[12] = GFS2_DIF_EXHASH,
144144
[14] = GFS2_DIF_INHERIT_JDATA,
145+
[17] = GFS2_DIF_TOPDIR,
145146
};
146147

147148
static const u32 gfs2_to_fsflags[32] = {
@@ -150,6 +151,7 @@ static const u32 gfs2_to_fsflags[32] = {
150151
[gfs2fl_AppendOnly] = FS_APPEND_FL,
151152
[gfs2fl_NoAtime] = FS_NOATIME_FL,
152153
[gfs2fl_ExHash] = FS_INDEX_FL,
154+
[gfs2fl_TopLevel] = FS_TOPDIR_FL,
153155
[gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
154156
};
155157

@@ -203,6 +205,7 @@ void gfs2_set_inode_flags(struct inode *inode)
203205
GFS2_DIF_NOATIME| \
204206
GFS2_DIF_SYNC| \
205207
GFS2_DIF_SYSTEM| \
208+
GFS2_DIF_TOPDIR| \
206209
GFS2_DIF_INHERIT_JDATA)
207210

208211
/**
@@ -298,6 +301,7 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
298301

299302
gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
300303
if (!S_ISDIR(inode->i_mode)) {
304+
gfsflags &= ~GFS2_DIF_TOPDIR;
301305
if (gfsflags & GFS2_DIF_INHERIT_JDATA)
302306
gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA);
303307
return do_gfs2_set_flags(filp, gfsflags, ~0);
@@ -366,7 +370,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
366370
u64 pos = page->index << PAGE_CACHE_SHIFT;
367371
unsigned int data_blocks, ind_blocks, rblocks;
368372
struct gfs2_holder gh;
369-
struct gfs2_qadata *qa;
370373
loff_t size;
371374
int ret;
372375

@@ -376,6 +379,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
376379
*/
377380
vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
378381

382+
ret = gfs2_rs_alloc(ip);
383+
if (ret)
384+
return ret;
385+
386+
atomic_set(&ip->i_res->rs_sizehint,
387+
PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift);
388+
379389
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
380390
ret = gfs2_glock_nq(&gh);
381391
if (ret)
@@ -393,14 +403,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
393403
goto out_unlock;
394404
}
395405

396-
ret = -ENOMEM;
397-
qa = gfs2_qadata_get(ip);
398-
if (qa == NULL)
406+
ret = gfs2_rindex_update(sdp);
407+
if (ret)
399408
goto out_unlock;
400409

401410
ret = gfs2_quota_lock_check(ip);
402411
if (ret)
403-
goto out_alloc_put;
412+
goto out_unlock;
404413
gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
405414
ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
406415
if (ret)
@@ -447,8 +456,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
447456
gfs2_inplace_release(ip);
448457
out_quota_unlock:
449458
gfs2_quota_unlock(ip);
450-
out_alloc_put:
451-
gfs2_qadata_put(ip);
452459
out_unlock:
453460
gfs2_glock_dq(&gh);
454461
out:
@@ -567,16 +574,14 @@ static int gfs2_open(struct inode *inode, struct file *file)
567574

568575
static int gfs2_release(struct inode *inode, struct file *file)
569576
{
570-
struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
571-
struct gfs2_file *fp;
577+
struct gfs2_inode *ip = GFS2_I(inode);
572578

573-
fp = file->private_data;
579+
kfree(file->private_data);
574580
file->private_data = NULL;
575581

576-
if (gfs2_assert_warn(sdp, fp))
577-
return -EIO;
578-
579-
kfree(fp);
582+
if ((file->f_mode & FMODE_WRITE) &&
583+
(atomic_read(&inode->i_writecount) == 1))
584+
gfs2_rs_delete(ip);
580585

581586
return 0;
582587
}
@@ -653,12 +658,20 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
653658
unsigned long nr_segs, loff_t pos)
654659
{
655660
struct file *file = iocb->ki_filp;
661+
size_t writesize = iov_length(iov, nr_segs);
662+
struct dentry *dentry = file->f_dentry;
663+
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
664+
struct gfs2_sbd *sdp;
665+
int ret;
656666

667+
sdp = GFS2_SB(file->f_mapping->host);
668+
ret = gfs2_rs_alloc(ip);
669+
if (ret)
670+
return ret;
671+
672+
atomic_set(&ip->i_res->rs_sizehint, writesize >> sdp->sd_sb.sb_bsize_shift);
657673
if (file->f_flags & O_APPEND) {
658-
struct dentry *dentry = file->f_dentry;
659-
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
660674
struct gfs2_holder gh;
661-
int ret;
662675

663676
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
664677
if (ret)
@@ -751,7 +764,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
751764
struct gfs2_inode *ip = GFS2_I(inode);
752765
unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
753766
loff_t bytes, max_bytes;
754-
struct gfs2_qadata *qa;
755767
int error;
756768
const loff_t pos = offset;
757769
const loff_t count = len;
@@ -774,11 +786,17 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
774786
if (bytes == 0)
775787
bytes = sdp->sd_sb.sb_bsize;
776788

789+
error = gfs2_rs_alloc(ip);
790+
if (error)
791+
return error;
792+
777793
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);
778794
error = gfs2_glock_nq(&ip->i_gh);
779795
if (unlikely(error))
780796
goto out_uninit;
781797

798+
atomic_set(&ip->i_res->rs_sizehint, len >> sdp->sd_sb.sb_bsize_shift);
799+
782800
while (len > 0) {
783801
if (len < bytes)
784802
bytes = len;
@@ -787,15 +805,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
787805
offset += bytes;
788806
continue;
789807
}
790-
qa = gfs2_qadata_get(ip);
791-
if (!qa) {
792-
error = -ENOMEM;
793-
goto out_unlock;
794-
}
795-
796808
error = gfs2_quota_lock_check(ip);
797809
if (error)
798-
goto out_alloc_put;
810+
goto out_unlock;
799811

800812
retry:
801813
gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
@@ -835,7 +847,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
835847
offset += max_bytes;
836848
gfs2_inplace_release(ip);
837849
gfs2_quota_unlock(ip);
838-
gfs2_qadata_put(ip);
839850
}
840851

841852
if (error == 0)
@@ -846,8 +857,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
846857
gfs2_inplace_release(ip);
847858
out_qunlock:
848859
gfs2_quota_unlock(ip);
849-
out_alloc_put:
850-
gfs2_qadata_put(ip);
851860
out_unlock:
852861
gfs2_glock_dq(&ip->i_gh);
853862
out_uninit:

0 commit comments

Comments
 (0)