Commit 801b0365 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 614a6d43 15e1c960
...@@ -614,7 +614,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, ...@@ -614,7 +614,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
unsigned int data_blocks = 0, ind_blocks = 0, rblocks; unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
int alloc_required; int alloc_required;
int error = 0; int error = 0;
struct gfs2_qadata *qa = NULL;
pgoff_t index = pos >> PAGE_CACHE_SHIFT; pgoff_t index = pos >> PAGE_CACHE_SHIFT;
unsigned from = pos & (PAGE_CACHE_SIZE - 1); unsigned from = pos & (PAGE_CACHE_SIZE - 1);
struct page *page; struct page *page;
...@@ -638,15 +637,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, ...@@ -638,15 +637,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
if (alloc_required) { if (alloc_required) {
qa = gfs2_qadata_get(ip);
if (!qa) {
error = -ENOMEM;
goto out_unlock;
}
error = gfs2_quota_lock_check(ip); error = gfs2_quota_lock_check(ip);
if (error) if (error)
goto out_alloc_put; goto out_unlock;
error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
if (error) if (error)
...@@ -708,8 +701,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, ...@@ -708,8 +701,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
out_qunlock: out_qunlock:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
out_alloc_put:
gfs2_qadata_put(ip);
} }
out_unlock: out_unlock:
if (&ip->i_inode == sdp->sd_rindex) { if (&ip->i_inode == sdp->sd_rindex) {
...@@ -846,7 +837,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, ...@@ -846,7 +837,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
struct gfs2_sbd *sdp = GFS2_SB(inode); struct gfs2_sbd *sdp = GFS2_SB(inode);
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
struct buffer_head *dibh; struct buffer_head *dibh;
struct gfs2_qadata *qa = ip->i_qadata;
unsigned int from = pos & (PAGE_CACHE_SIZE - 1); unsigned int from = pos & (PAGE_CACHE_SIZE - 1);
unsigned int to = from + len; unsigned int to = from + len;
int ret; int ret;
...@@ -878,12 +868,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, ...@@ -878,12 +868,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
brelse(dibh); brelse(dibh);
failed: failed:
gfs2_trans_end(sdp); gfs2_trans_end(sdp);
if (ip->i_res) if (gfs2_mb_reserved(ip))
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
if (qa) { if (ip->i_res->rs_qa_qd_num)
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
gfs2_qadata_put(ip);
}
if (inode == sdp->sd_rindex) { if (inode == sdp->sd_rindex) {
gfs2_glock_dq(&m_ip->i_gh); gfs2_glock_dq(&m_ip->i_gh);
gfs2_holder_uninit(&m_ip->i_gh); gfs2_holder_uninit(&m_ip->i_gh);
......
...@@ -785,6 +785,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, ...@@ -785,6 +785,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
if (error) if (error)
goto out_rlist; goto out_rlist;
if (gfs2_rs_active(ip->i_res)) /* needs to be done with the rgrp glock held */
gfs2_rs_deltree(ip->i_res);
error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE + error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
RES_INDIRECT + RES_STATFS + RES_QUOTA, RES_INDIRECT + RES_STATFS + RES_QUOTA,
revokes); revokes);
...@@ -1045,12 +1048,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size) ...@@ -1045,12 +1048,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift; lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift;
find_metapath(sdp, lblock, &mp, ip->i_height); find_metapath(sdp, lblock, &mp, ip->i_height);
if (!gfs2_qadata_get(ip)) error = gfs2_rindex_update(sdp);
return -ENOMEM; if (error)
return error;
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
goto out; return error;
while (height--) { while (height--) {
struct strip_mine sm; struct strip_mine sm;
...@@ -1064,8 +1068,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size) ...@@ -1064,8 +1068,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
gfs2_quota_unhold(ip); gfs2_quota_unhold(ip);
out:
gfs2_qadata_put(ip);
return error; return error;
} }
...@@ -1167,19 +1169,14 @@ static int do_grow(struct inode *inode, u64 size) ...@@ -1167,19 +1169,14 @@ static int do_grow(struct inode *inode, u64 size)
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode); struct gfs2_sbd *sdp = GFS2_SB(inode);
struct buffer_head *dibh; struct buffer_head *dibh;
struct gfs2_qadata *qa = NULL;
int error; int error;
int unstuff = 0; int unstuff = 0;
if (gfs2_is_stuffed(ip) && if (gfs2_is_stuffed(ip) &&
(size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) {
qa = gfs2_qadata_get(ip);
if (qa == NULL)
return -ENOMEM;
error = gfs2_quota_lock_check(ip); error = gfs2_quota_lock_check(ip);
if (error) if (error)
goto do_grow_alloc_put; return error;
error = gfs2_inplace_reserve(ip, 1); error = gfs2_inplace_reserve(ip, 1);
if (error) if (error)
...@@ -1214,8 +1211,6 @@ static int do_grow(struct inode *inode, u64 size) ...@@ -1214,8 +1211,6 @@ static int do_grow(struct inode *inode, u64 size)
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
do_grow_qunlock: do_grow_qunlock:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
do_grow_alloc_put:
gfs2_qadata_put(ip);
} }
return error; return error;
} }
......
...@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, ...@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
if (!ht) if (!ht)
return -ENOMEM; return -ENOMEM;
if (!gfs2_qadata_get(dip)) {
error = -ENOMEM;
goto out;
}
error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
goto out_put; goto out;
/* Count the number of leaves */ /* Count the number of leaves */
bh = leaf_bh; bh = leaf_bh;
...@@ -1942,8 +1937,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, ...@@ -1942,8 +1937,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
out_rlist: out_rlist:
gfs2_rlist_free(&rlist); gfs2_rlist_free(&rlist);
gfs2_quota_unhold(dip); gfs2_quota_unhold(dip);
out_put:
gfs2_qadata_put(dip);
out: out:
kfree(ht); kfree(ht);
return error; return error;
......
...@@ -142,6 +142,7 @@ static const u32 fsflags_to_gfs2[32] = { ...@@ -142,6 +142,7 @@ static const u32 fsflags_to_gfs2[32] = {
[7] = GFS2_DIF_NOATIME, [7] = GFS2_DIF_NOATIME,
[12] = GFS2_DIF_EXHASH, [12] = GFS2_DIF_EXHASH,
[14] = GFS2_DIF_INHERIT_JDATA, [14] = GFS2_DIF_INHERIT_JDATA,
[17] = GFS2_DIF_TOPDIR,
}; };
static const u32 gfs2_to_fsflags[32] = { static const u32 gfs2_to_fsflags[32] = {
...@@ -150,6 +151,7 @@ static const u32 gfs2_to_fsflags[32] = { ...@@ -150,6 +151,7 @@ static const u32 gfs2_to_fsflags[32] = {
[gfs2fl_AppendOnly] = FS_APPEND_FL, [gfs2fl_AppendOnly] = FS_APPEND_FL,
[gfs2fl_NoAtime] = FS_NOATIME_FL, [gfs2fl_NoAtime] = FS_NOATIME_FL,
[gfs2fl_ExHash] = FS_INDEX_FL, [gfs2fl_ExHash] = FS_INDEX_FL,
[gfs2fl_TopLevel] = FS_TOPDIR_FL,
[gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL, [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
}; };
...@@ -203,6 +205,7 @@ void gfs2_set_inode_flags(struct inode *inode) ...@@ -203,6 +205,7 @@ void gfs2_set_inode_flags(struct inode *inode)
GFS2_DIF_NOATIME| \ GFS2_DIF_NOATIME| \
GFS2_DIF_SYNC| \ GFS2_DIF_SYNC| \
GFS2_DIF_SYSTEM| \ GFS2_DIF_SYSTEM| \
GFS2_DIF_TOPDIR| \
GFS2_DIF_INHERIT_JDATA) GFS2_DIF_INHERIT_JDATA)
/** /**
...@@ -298,6 +301,7 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) ...@@ -298,6 +301,7 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags); gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
if (!S_ISDIR(inode->i_mode)) { if (!S_ISDIR(inode->i_mode)) {
gfsflags &= ~GFS2_DIF_TOPDIR;
if (gfsflags & GFS2_DIF_INHERIT_JDATA) if (gfsflags & GFS2_DIF_INHERIT_JDATA)
gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA); gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA);
return do_gfs2_set_flags(filp, gfsflags, ~0); 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) ...@@ -366,7 +370,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
u64 pos = page->index << PAGE_CACHE_SHIFT; u64 pos = page->index << PAGE_CACHE_SHIFT;
unsigned int data_blocks, ind_blocks, rblocks; unsigned int data_blocks, ind_blocks, rblocks;
struct gfs2_holder gh; struct gfs2_holder gh;
struct gfs2_qadata *qa;
loff_t size; loff_t size;
int ret; int ret;
...@@ -376,6 +379,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -376,6 +379,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
*/ */
vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
ret = gfs2_rs_alloc(ip);
if (ret)
return ret;
atomic_set(&ip->i_res->rs_sizehint,
PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift);
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
ret = gfs2_glock_nq(&gh); ret = gfs2_glock_nq(&gh);
if (ret) if (ret)
...@@ -393,14 +403,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -393,14 +403,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
goto out_unlock; goto out_unlock;
} }
ret = -ENOMEM; ret = gfs2_rindex_update(sdp);
qa = gfs2_qadata_get(ip); if (ret)
if (qa == NULL)
goto out_unlock; goto out_unlock;
ret = gfs2_quota_lock_check(ip); ret = gfs2_quota_lock_check(ip);
if (ret) if (ret)
goto out_alloc_put; goto out_unlock;
gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
if (ret) if (ret)
...@@ -447,8 +456,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -447,8 +456,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
out_quota_unlock: out_quota_unlock:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
out_alloc_put:
gfs2_qadata_put(ip);
out_unlock: out_unlock:
gfs2_glock_dq(&gh); gfs2_glock_dq(&gh);
out: out:
...@@ -567,16 +574,14 @@ static int gfs2_open(struct inode *inode, struct file *file) ...@@ -567,16 +574,14 @@ static int gfs2_open(struct inode *inode, struct file *file)
static int gfs2_release(struct inode *inode, struct file *file) static int gfs2_release(struct inode *inode, struct file *file)
{ {
struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_file *fp;
fp = file->private_data; kfree(file->private_data);
file->private_data = NULL; file->private_data = NULL;
if (gfs2_assert_warn(sdp, fp)) if ((file->f_mode & FMODE_WRITE) &&
return -EIO; (atomic_read(&inode->i_writecount) == 1))
gfs2_rs_delete(ip);
kfree(fp);
return 0; return 0;
} }
...@@ -653,12 +658,20 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -653,12 +658,20 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos) unsigned long nr_segs, loff_t pos)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
size_t writesize = iov_length(iov, nr_segs);
struct dentry *dentry = file->f_dentry;
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
struct gfs2_sbd *sdp;
int ret;
sdp = GFS2_SB(file->f_mapping->host);
ret = gfs2_rs_alloc(ip);
if (ret)
return ret;
atomic_set(&ip->i_res->rs_sizehint, writesize >> sdp->sd_sb.sb_bsize_shift);
if (file->f_flags & O_APPEND) { if (file->f_flags & O_APPEND) {
struct dentry *dentry = file->f_dentry;
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
struct gfs2_holder gh; struct gfs2_holder gh;
int ret;
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
if (ret) if (ret)
...@@ -751,7 +764,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -751,7 +764,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
unsigned int data_blocks = 0, ind_blocks = 0, rblocks; unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
loff_t bytes, max_bytes; loff_t bytes, max_bytes;
struct gfs2_qadata *qa;
int error; int error;
const loff_t pos = offset; const loff_t pos = offset;
const loff_t count = len; const loff_t count = len;
...@@ -774,11 +786,17 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -774,11 +786,17 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
if (bytes == 0) if (bytes == 0)
bytes = sdp->sd_sb.sb_bsize; bytes = sdp->sd_sb.sb_bsize;
error = gfs2_rs_alloc(ip);
if (error)
return error;
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);
error = gfs2_glock_nq(&ip->i_gh); error = gfs2_glock_nq(&ip->i_gh);
if (unlikely(error)) if (unlikely(error))
goto out_uninit; goto out_uninit;
atomic_set(&ip->i_res->rs_sizehint, len >> sdp->sd_sb.sb_bsize_shift);
while (len > 0) { while (len > 0) {
if (len < bytes) if (len < bytes)
bytes = len; bytes = len;
...@@ -787,15 +805,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -787,15 +805,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
offset += bytes; offset += bytes;
continue; continue;
} }
qa = gfs2_qadata_get(ip);
if (!qa) {
error = -ENOMEM;
goto out_unlock;
}
error = gfs2_quota_lock_check(ip); error = gfs2_quota_lock_check(ip);
if (error) if (error)
goto out_alloc_put; goto out_unlock;
retry: retry:
gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); 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, ...@@ -835,7 +847,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
offset += max_bytes; offset += max_bytes;
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
gfs2_qadata_put(ip);
} }
if (error == 0) if (error == 0)
...@@ -846,8 +857,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -846,8 +857,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
out_qunlock: out_qunlock:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
out_alloc_put:
gfs2_qadata_put(ip);
out_unlock: out_unlock:
gfs2_glock_dq(&ip->i_gh); gfs2_glock_dq(&ip->i_gh);
out_uninit: out_uninit:
......
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
#include "trace_gfs2.h" #include "trace_gfs2.h"
struct gfs2_glock_iter { struct gfs2_glock_iter {
int hash; /* hash bucket index */ int hash; /* hash bucket index */
struct gfs2_sbd *sdp; /* incore superblock */ unsigned nhash; /* Index within current bucket */
struct gfs2_glock *gl; /* current glock struct */ struct gfs2_sbd *sdp; /* incore superblock */
char string[512]; /* scratch space */ struct gfs2_glock *gl; /* current glock struct */
loff_t last_pos; /* last position */
}; };
typedef void (*glock_examiner) (struct gfs2_glock * gl); typedef void (*glock_examiner) (struct gfs2_glock * gl);
...@@ -767,6 +768,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, ...@@ -767,6 +768,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0; gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0;
gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0; gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0;
memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb)); memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
memset(gl->gl_lvb, 0, 32 * sizeof(char));
gl->gl_lksb.sb_lvbptr = gl->gl_lvb; gl->gl_lksb.sb_lvbptr = gl->gl_lvb;
gl->gl_tchange = jiffies; gl->gl_tchange = jiffies;
gl->gl_object = NULL; gl->gl_object = NULL;
...@@ -948,9 +950,7 @@ void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...) ...@@ -948,9 +950,7 @@ void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
if (seq) { if (seq) {
struct gfs2_glock_iter *gi = seq->private; seq_vprintf(seq, fmt, args);
vsprintf(gi->string, fmt, args);
seq_printf(seq, gi->string);
} else { } else {
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; vaf.va = &args;
...@@ -1854,8 +1854,14 @@ static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi) ...@@ -1854,8 +1854,14 @@ static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
gl = gi->gl; gl = gi->gl;
if (gl) { if (gl) {
gi->gl = glock_hash_next(gl); gi->gl = glock_hash_next(gl);
gi->nhash++;
} else { } else {
if (gi->hash >= GFS2_GL_HASH_SIZE) {
rcu_read_unlock();
return 1;
}
gi->gl = glock_hash_chain(gi->hash); gi->gl = glock_hash_chain(gi->hash);
gi->nhash = 0;
} }
while (gi->gl == NULL) { while (gi->gl == NULL) {
gi->hash++; gi->hash++;
...@@ -1864,6 +1870,7 @@ static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi) ...@@ -1864,6 +1870,7 @@ static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
return 1; return 1;
} }
gi->gl = glock_hash_chain(gi->hash); gi->gl = glock_hash_chain(gi->hash);
gi->nhash = 0;
} }
/* Skip entries for other sb and dead entries */ /* Skip entries for other sb and dead entries */
} while (gi->sdp != gi->gl->gl_sbd || atomic_read(&gi->gl->gl_ref) == 0); } while (gi->sdp != gi->gl->gl_sbd || atomic_read(&gi->gl->gl_ref) == 0);
...@@ -1876,7 +1883,12 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -1876,7 +1883,12 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
struct gfs2_glock_iter *gi = seq->private; struct gfs2_glock_iter *gi = seq->private;
loff_t n = *pos; loff_t n = *pos;
gi->hash = 0; if (gi->last_pos <= *pos)
n = gi->nhash + (*pos - gi->last_pos);
else
gi->hash = 0;
gi->nhash = 0;
rcu_read_lock(); rcu_read_lock();
do { do {
...@@ -1884,6 +1896,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -1884,6 +1896,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
return NULL; return NULL;
} while (n--); } while (n--);
gi->last_pos = *pos;
return gi->gl; return gi->gl;
} }
...@@ -1893,7 +1906,7 @@ static void *gfs2_glock_seq_next(struct seq_file *seq, void *iter_ptr, ...@@ -1893,7 +1906,7 @@ static void *gfs2_glock_seq_next(struct seq_file *seq, void *iter_ptr,
struct gfs2_glock_iter *gi = seq->private; struct gfs2_glock_iter *gi = seq->private;
(*pos)++; (*pos)++;
gi->last_pos = *pos;
if (gfs2_glock_iter_next(gi)) if (gfs2_glock_iter_next(gi))
return NULL; return NULL;
...@@ -1964,6 +1977,8 @@ static const struct seq_operations gfs2_sbstats_seq_ops = { ...@@ -1964,6 +1977,8 @@ static const struct seq_operations gfs2_sbstats_seq_ops = {
.show = gfs2_sbstats_seq_show, .show = gfs2_sbstats_seq_show,
}; };
#define GFS2_SEQ_GOODSIZE min(PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER, 65536UL)
static int gfs2_glocks_open(struct inode *inode, struct file *file) static int gfs2_glocks_open(struct inode *inode, struct file *file)
{ {
int ret = seq_open_private(file, &gfs2_glock_seq_ops, int ret = seq_open_private(file, &gfs2_glock_seq_ops,
...@@ -1972,6 +1987,9 @@ static int gfs2_glocks_open(struct inode *inode, struct file *file) ...@@ -1972,6 +1987,9 @@ static int gfs2_glocks_open(struct inode *inode, struct file *file)
struct seq_file *seq = file->private_data; struct seq_file *seq = file->private_data;
struct gfs2_glock_iter *gi = seq->private; struct gfs2_glock_iter *gi = seq->private;
gi->sdp = inode->i_private; gi->sdp = inode->i_private;
seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN);
if (seq->buf)
seq->size = GFS2_SEQ_GOODSIZE;
} }
return ret; return ret;
} }
...@@ -1984,6 +2002,9 @@ static int gfs2_glstats_open(struct inode *inode, struct file *file) ...@@ -1984,6 +2002,9 @@ static int gfs2_glstats_open(struct inode *inode, struct file *file)
struct seq_file *seq = file->private_data; struct seq_file *seq = file->private_data;
struct gfs2_glock_iter *gi = seq->private; struct gfs2_glock_iter *gi = seq->private;
gi->sdp = inode->i_private; gi->sdp = inode->i_private;
seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN);
if (seq->buf)
seq->size = GFS2_SEQ_GOODSIZE;
} }
return ret; return ret;
} }
......
...@@ -84,17 +84,22 @@ struct gfs2_rgrpd { ...@@ -84,17 +84,22 @@ struct gfs2_rgrpd {
u32 rd_data; /* num of data blocks in rgrp */ u32 rd_data; /* num of data blocks in rgrp */
u32 rd_bitbytes; /* number of bytes in data bitmaps */ u32 rd_bitbytes; /* number of bytes in data bitmaps */
u32 rd_free; u32 rd_free;
u32 rd_reserved; /* number of blocks reserved */
u32 rd_free_clone; u32 rd_free_clone;
u32 rd_dinodes; u32 rd_dinodes;
u64 rd_igeneration; u64 rd_igeneration;
struct gfs2_bitmap *rd_bits; struct gfs2_bitmap *rd_bits;
struct gfs2_sbd *rd_sbd; struct gfs2_sbd *rd_sbd;
struct gfs2_rgrp_lvb *rd_rgl;
u32 rd_last_alloc; u32 rd_last_alloc;
u32 rd_flags; u32 rd_flags;
#define GFS2_RDF_CHECK 0x10000000 /* check for unlinked inodes */ #define GFS2_RDF_CHECK 0x10000000 /* check for unlinked inodes */
#define GFS2_RDF_UPTODATE 0x20000000 /* rg is up to date */ #define GFS2_RDF_UPTODATE 0x20000000 /* rg is up to date */
#define GFS2_RDF_ERROR 0x40000000 /* error in rg */ #define GFS2_RDF_ERROR 0x40000000 /* error in rg */
#define GFS2_RDF_MASK 0xf0000000 /* mask for internal flags */ #define GFS2_RDF_MASK 0xf0000000 /* mask for internal flags */
spinlock_t rd_rsspin; /* protects reservation related vars */
struct rb_root rd_rstree; /* multi-block reservation tree */
u32 rd_rs_cnt; /* count of current reservations */
}; };
enum gfs2_state_bits { enum gfs2_state_bits {
...@@ -232,6 +237,38 @@ struct gfs2_holder { ...@@ -232,6 +237,38 @@ struct gfs2_holder {
unsigned long gh_ip; unsigned long gh_ip;
}; };
/* Resource group multi-block reservation, in order of appearance:
Step 1. Function prepares to write, allocates a mb, sets the size hint.
Step 2. User calls inplace_reserve to target an rgrp, sets the rgrp info
Step 3. Function get_local_rgrp locks the rgrp, determines which bits to use
Step 4. Bits are assigned from the rgrp based on either the reservation
or wherever it can.
*/
struct gfs2_blkreserv {
/* components used during write (step 1): */
atomic_t rs_sizehint; /* hint of the write size */
/* components used during inplace_reserve (step 2): */
u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */
/* components used during get_local_rgrp (step 3): */
struct gfs2_rgrpd *rs_rgd; /* pointer to the gfs2_rgrpd */
struct gfs2_holder rs_rgd_gh; /* Filled in by get_local_rgrp */
struct rb_node rs_node; /* link to other block reservations */
/* components used during block searches and assignments (step 4): */
struct gfs2_bitmap *rs_bi; /* bitmap for the current allocation */
u32 rs_biblk; /* start block relative to the bi */
u32 rs_free; /* how many blocks are still free */
/* ancillary quota stuff */
struct gfs2_quota_data *rs_qa_qd[2 * MAXQUOTAS];
struct gfs2_holder rs_qa_qd_ghs[2 * MAXQUOTAS];
unsigned int rs_qa_qd_num;
};
enum { enum {
GLF_LOCK = 1, GLF_LOCK = 1,
GLF_DEMOTE = 3, GLF_DEMOTE = 3,
...@@ -289,18 +326,6 @@ struct gfs2_glock { ...@@ -289,18 +326,6 @@ struct gfs2_glock {
#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ #define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */
struct gfs2_qadata { /* quota allocation data */
/* Quota stuff */
struct gfs2_quota_data *qa_qd[2*MAXQUOTAS];
struct gfs2_holder qa_qd_ghs[2*MAXQUOTAS];
unsigned int qa_qd_num;
};
struct gfs2_blkreserv {
u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */
struct gfs2_holder rs_rgd_gh; /* Filled in by gfs2_inplace_reserve() */
};
enum { enum {
GIF_INVALID = 0, GIF_INVALID = 0,
GIF_QD_LOCKED = 1, GIF_QD_LOCKED = 1,
...@@ -308,7 +333,6 @@ enum { ...@@ -308,7 +333,6 @@ enum {
GIF_SW_PAGED = 3, GIF_SW_PAGED = 3,
}; };
struct gfs2_inode { struct gfs2_inode {
struct inode i_inode; struct inode i_inode;
u64 i_no_addr; u64 i_no_addr;
...@@ -319,8 +343,7 @@ struct gfs2_inode { ...@@ -319,8 +343,7 @@ struct gfs2_inode {
struct gfs2_glock *i_gl; /* Move into i_gh? */ struct gfs2_glock *i_gl; /* Move into i_gh? */
struct gfs2_holder i_iopen_gh; struct gfs2_holder i_iopen_gh;
struct gfs2_holder i_gh; /* for prepare/commit_write only */ struct gfs2_holder i_gh; /* for prepare/commit_write only */
struct gfs2_qadata *i_qadata; /* quota allocation data */ struct gfs2_blkreserv *i_res; /* rgrp multi-block reservation */
struct gfs2_blkreserv *i_res; /* resource group block reservation */
struct gfs2_rgrpd *i_rgd; struct gfs2_rgrpd *i_rgd;
u64 i_goal; /* goal block for allocations */ u64 i_goal; /* goal block for allocations */
struct rw_semaphore i_rw_mutex; struct rw_semaphore i_rw_mutex;
...@@ -473,6 +496,7 @@ struct gfs2_args { ...@@ -473,6 +496,7 @@ struct gfs2_args {
unsigned int ar_discard:1; /* discard requests */ unsigned int ar_discard:1; /* discard requests */
unsigned int ar_errors:2; /* errors=withdraw | panic */ unsigned int ar_errors:2; /* errors=withdraw | panic */
unsigned int ar_nobarrier:1; /* do not send barriers */ unsigned int ar_nobarrier:1; /* do not send barriers */
unsigned int ar_rgrplvb:1; /* use lvbs for rgrp info */
int ar_commit; /* Commit interval */ int ar_commit; /* Commit interval */
int ar_statfs_quantum; /* The fast statfs interval */ int ar_statfs_quantum; /* The fast statfs interval */
int ar_quota_quantum; /* The quota interval */ int ar_quota_quantum; /* The quota interval */
......
...@@ -521,12 +521,13 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, ...@@ -521,12 +521,13 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
int error; int error;
munge_mode_uid_gid(dip, &mode, &uid, &gid); munge_mode_uid_gid(dip, &mode, &uid, &gid);
if (!gfs2_qadata_get(dip)) error = gfs2_rindex_update(sdp);
return -ENOMEM; if (error)
return error;
error = gfs2_quota_lock(dip, uid, gid); error = gfs2_quota_lock(dip, uid, gid);
if (error) if (error)
goto out; return error;
error = gfs2_quota_check(dip, uid, gid); error = gfs2_quota_check(dip, uid, gid);
if (error) if (error)
...@@ -542,8 +543,6 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, ...@@ -542,8 +543,6 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
out_quota: out_quota:
gfs2_quota_unlock(dip); gfs2_quota_unlock(dip);
out:
gfs2_qadata_put(dip);
return error; return error;
} }
...@@ -551,14 +550,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, ...@@ -551,14 +550,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
struct gfs2_inode *ip) struct gfs2_inode *ip)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
struct gfs2_qadata *qa;
int alloc_required; int alloc_required;
struct buffer_head *dibh; struct buffer_head *dibh;
int error; int error;
qa = gfs2_qadata_get(dip); error = gfs2_rindex_update(sdp);
if (!qa) if (error)
return -ENOMEM; return error;
error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
...@@ -605,13 +603,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, ...@@ -605,13 +603,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
gfs2_trans_end(sdp); gfs2_trans_end(sdp);
fail_ipreserv: fail_ipreserv:
gfs2_inplace_release(dip); if (alloc_required)
gfs2_inplace_release(dip);
fail_quota_locks: fail_quota_locks:
gfs2_quota_unlock(dip); gfs2_quota_unlock(dip);
fail: fail:
gfs2_qadata_put(dip);
return error; return error;
} }
...@@ -657,7 +655,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -657,7 +655,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
const struct qstr *name = &dentry->d_name; const struct qstr *name = &dentry->d_name;
struct gfs2_holder ghs[2]; struct gfs2_holder ghs[2];
struct inode *inode = NULL; struct inode *inode = NULL;
struct gfs2_inode *dip = GFS2_I(dir); struct gfs2_inode *dip = GFS2_I(dir), *ip;
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
struct gfs2_inum_host inum = { .no_addr = 0, .no_formal_ino = 0 }; struct gfs2_inum_host inum = { .no_addr = 0, .no_formal_ino = 0 };
int error; int error;
...@@ -667,6 +665,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -667,6 +665,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
if (!name->len || name->len > GFS2_FNAMESIZE) if (!name->len || name->len > GFS2_FNAMESIZE)
return -ENAMETOOLONG; return -ENAMETOOLONG;
/* We need a reservation to allocate the new dinode block. The
directory ip temporarily points to the reservation, but this is
being done to get a set of contiguous blocks for the new dinode.
Since this is a create, we don't have a sizehint yet, so it will
have to use the minimum reservation size. */
error = gfs2_rs_alloc(dip);
if (error)
return error;
error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
if (error) if (error)
goto fail; goto fail;
...@@ -700,19 +707,29 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -700,19 +707,29 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
if (IS_ERR(inode)) if (IS_ERR(inode))
goto fail_gunlock2; goto fail_gunlock2;
error = gfs2_inode_refresh(GFS2_I(inode)); ip = GFS2_I(inode);
error = gfs2_inode_refresh(ip);
if (error) if (error)
goto fail_gunlock2; goto fail_gunlock2;
/* The newly created inode needs a reservation so it can allocate
xattrs. At the same time, we want new blocks allocated to the new
dinode to be as contiguous as possible. Since we allocated the
dinode block under the directory's reservation, we transfer
ownership of that reservation to the new inode. The directory
doesn't need a reservation unless it needs a new allocation. */
ip->i_res = dip->i_res;
dip->i_res = NULL;
error = gfs2_acl_create(dip, inode); error = gfs2_acl_create(dip, inode);
if (error) if (error)
goto fail_gunlock2; goto fail_gunlock2;
error = gfs2_security_init(dip, GFS2_I(inode), name); error = gfs2_security_init(dip, ip, name);
if (error) if (error)
goto fail_gunlock2; goto fail_gunlock2;
error = link_dinode(dip, name, GFS2_I(inode)); error = link_dinode(dip, name, ip);
if (error) if (error)
goto fail_gunlock2; goto fail_gunlock2;
...@@ -722,10 +739,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -722,10 +739,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
gfs2_trans_end(sdp); gfs2_trans_end(sdp);
/* Check if we reserved space in the rgrp. Function link_dinode may /* Check if we reserved space in the rgrp. Function link_dinode may
not, depending on whether alloc is required. */ not, depending on whether alloc is required. */
if (dip->i_res) if (gfs2_mb_reserved(dip))
gfs2_inplace_release(dip); gfs2_inplace_release(dip);
gfs2_quota_unlock(dip); gfs2_quota_unlock(dip);
gfs2_qadata_put(dip);
mark_inode_dirty(inode); mark_inode_dirty(inode);
gfs2_glock_dq_uninit_m(2, ghs); gfs2_glock_dq_uninit_m(2, ghs);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
...@@ -740,6 +756,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -740,6 +756,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
iput(inode); iput(inode);
} }
fail: fail:
gfs2_rs_delete(dip);
if (bh) if (bh)
brelse(bh); brelse(bh);
return error; return error;
...@@ -816,6 +833,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, ...@@ -816,6 +833,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
return -EPERM; return -EPERM;
error = gfs2_rs_alloc(dip);
if (error)
return error;
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
...@@ -867,16 +888,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, ...@@ -867,16 +888,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
error = 0; error = 0;
if (alloc_required) { if (alloc_required) {
struct gfs2_qadata *qa = gfs2_qadata_get(dip);
if (!qa) {
error = -ENOMEM;
goto out_gunlock;
}
error = gfs2_quota_lock_check(dip); error = gfs2_quota_lock_check(dip);
if (error) if (error)
goto out_alloc; goto out_gunlock;
error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
if (error) if (error)
...@@ -919,9 +933,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, ...@@ -919,9 +933,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
out_gunlock_q: out_gunlock_q:
if (alloc_required) if (alloc_required)
gfs2_quota_unlock(dip); gfs2_quota_unlock(dip);
out_alloc:
if (alloc_required)
gfs2_qadata_put(dip);
out_gunlock: out_gunlock:
gfs2_glock_dq(ghs + 1); gfs2_glock_dq(ghs + 1);
out_child: out_child:
...@@ -1231,6 +1242,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -1231,6 +1242,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
if (error) if (error)
return error; return error;
error = gfs2_rs_alloc(ndip);
if (error)
return error;
if (odip != ndip) { if (odip != ndip) {
error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
0, &r_gh); 0, &r_gh);
...@@ -1354,16 +1369,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -1354,16 +1369,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
goto out_gunlock; goto out_gunlock;
if (alloc_required) { if (alloc_required) {
struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
if (!qa) {
error = -ENOMEM;
goto out_gunlock;
}
error = gfs2_quota_lock_check(ndip); error = gfs2_quota_lock_check(ndip);
if (error) if (error)
goto out_alloc; goto out_gunlock;
error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres); error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
if (error) if (error)
...@@ -1424,9 +1432,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -1424,9 +1432,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
out_gunlock_q: out_gunlock_q:
if (alloc_required) if (alloc_required)
gfs2_quota_unlock(ndip); gfs2_quota_unlock(ndip);
out_alloc:
if (alloc_required)
gfs2_qadata_put(ndip);
out_gunlock: out_gunlock:
while (x--) { while (x--) {
gfs2_glock_dq(ghs + x); gfs2_glock_dq(ghs + x);
...@@ -1587,12 +1592,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) ...@@ -1587,12 +1592,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
ogid = ngid = NO_QUOTA_CHANGE; ogid = ngid = NO_QUOTA_CHANGE;
if (!gfs2_qadata_get(ip))
return -ENOMEM;
error = gfs2_quota_lock(ip, nuid, ngid); error = gfs2_quota_lock(ip, nuid, ngid);
if (error) if (error)
goto out_alloc; return error;
if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
error = gfs2_quota_check(ip, nuid, ngid); error = gfs2_quota_check(ip, nuid, ngid);
...@@ -1618,8 +1620,6 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) ...@@ -1618,8 +1620,6 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
gfs2_trans_end(sdp); gfs2_trans_end(sdp);
out_gunlock_q: out_gunlock_q:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
out_alloc:
gfs2_qadata_put(ip);
return error; return error;
} }
...@@ -1641,6 +1641,10 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1641,6 +1641,10 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
struct gfs2_holder i_gh; struct gfs2_holder i_gh;
int error; int error;
error = gfs2_rs_alloc(ip);
if (error)
return error;
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
if (error) if (error)
return error; return error;
......
...@@ -401,9 +401,14 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) ...@@ -401,9 +401,14 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
goto out; goto out;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
gfs2_meta_check(sdp, bd->bd_bh);
gfs2_pin(sdp, bd->bd_bh);
mh = (struct gfs2_meta_header *)bd->bd_bh->b_data; mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
printk(KERN_ERR
"Attempting to add uninitialised block to journal (inplace block=%lld)\n",
(unsigned long long)bd->bd_bh->b_blocknr);
BUG();
}
gfs2_pin(sdp, bd->bd_bh);
mh->__pad0 = cpu_to_be64(0); mh->__pad0 = cpu_to_be64(0);
mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
sdp->sd_log_num_buf++; sdp->sd_log_num_buf++;
......
...@@ -43,7 +43,6 @@ static void gfs2_init_inode_once(void *foo) ...@@ -43,7 +43,6 @@ static void gfs2_init_inode_once(void *foo)
inode_init_once(&ip->i_inode); inode_init_once(&ip->i_inode);
init_rwsem(&ip->i_rw_mutex); init_rwsem(&ip->i_rw_mutex);
INIT_LIST_HEAD(&ip->i_trunc_list); INIT_LIST_HEAD(&ip->i_trunc_list);
ip->i_qadata = NULL;
ip->i_res = NULL; ip->i_res = NULL;
ip->i_hash_cache = NULL; ip->i_hash_cache = NULL;
} }
......
...@@ -213,8 +213,10 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, ...@@ -213,8 +213,10 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_sbd *sdp = gl->gl_sbd;
struct buffer_head *bh; struct buffer_head *bh;
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) {
*bhp = NULL;
return -EIO; return -EIO;
}
*bhp = bh = gfs2_getbuf(gl, blkno, CREATE); *bhp = bh = gfs2_getbuf(gl, blkno, CREATE);
...@@ -235,6 +237,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, ...@@ -235,6 +237,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
if (tr && tr->tr_touched) if (tr && tr->tr_touched)
gfs2_io_error_bh(sdp, bh); gfs2_io_error_bh(sdp, bh);
brelse(bh); brelse(bh);
*bhp = NULL;
return -EIO; return -EIO;
} }
......
...@@ -1118,20 +1118,33 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent ...@@ -1118,20 +1118,33 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
} }
error = init_names(sdp, silent); error = init_names(sdp, silent);
if (error) if (error) {
goto fail; /* In this case, we haven't initialized sysfs, so we have to
manually free the sdp. */
free_percpu(sdp->sd_lkstats);
kfree(sdp);
sb->s_fs_info = NULL;
return error;
}
snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s", sdp->sd_table_name); snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s", sdp->sd_table_name);
gfs2_create_debugfs_file(sdp);
error = gfs2_sys_fs_add(sdp); error = gfs2_sys_fs_add(sdp);
/*
* If we hit an error here, gfs2_sys_fs_add will have called function
* kobject_put which causes the sysfs usage count to go to zero, which
* causes sysfs to call function gfs2_sbd_release, which frees sdp.
* Subsequent error paths here will call gfs2_sys_fs_del, which also
* kobject_put to free sdp.
*/
if (error) if (error)
goto fail; return error;
gfs2_create_debugfs_file(sdp);
error = gfs2_lm_mount(sdp, silent); error = gfs2_lm_mount(sdp, silent);
if (error) if (error)
goto fail_sys; goto fail_debug;
error = init_locking(sdp, &mount_gh, DO); error = init_locking(sdp, &mount_gh, DO);
if (error) if (error)
...@@ -1215,12 +1228,12 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent ...@@ -1215,12 +1228,12 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
fail_lm: fail_lm:
gfs2_gl_hash_clear(sdp); gfs2_gl_hash_clear(sdp);
gfs2_lm_unmount(sdp); gfs2_lm_unmount(sdp);
fail_sys: fail_debug:
gfs2_sys_fs_del(sdp);
fail:
gfs2_delete_debugfs_file(sdp); gfs2_delete_debugfs_file(sdp);
free_percpu(sdp->sd_lkstats); free_percpu(sdp->sd_lkstats);
kfree(sdp); /* gfs2_sys_fs_del must be the last thing we do, since it causes
* sysfs to call function gfs2_sbd_release, which frees sdp. */
gfs2_sys_fs_del(sdp);
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
return error; return error;
} }
...@@ -1389,10 +1402,9 @@ static void gfs2_kill_sb(struct super_block *sb) ...@@ -1389,10 +1402,9 @@ static void gfs2_kill_sb(struct super_block *sb)
sdp->sd_root_dir = NULL; sdp->sd_root_dir = NULL;
sdp->sd_master_dir = NULL; sdp->sd_master_dir = NULL;
shrink_dcache_sb(sb); shrink_dcache_sb(sb);
kill_block_super(sb);
gfs2_delete_debugfs_file(sdp); gfs2_delete_debugfs_file(sdp);
free_percpu(sdp->sd_lkstats); free_percpu(sdp->sd_lkstats);
kfree(sdp); kill_block_super(sb);
} }
struct file_system_type gfs2_fs_type = { struct file_system_type gfs2_fs_type = {
......
...@@ -494,11 +494,15 @@ static void qdsb_put(struct gfs2_quota_data *qd) ...@@ -494,11 +494,15 @@ static void qdsb_put(struct gfs2_quota_data *qd)
int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_qadata *qa = ip->i_qadata; struct gfs2_quota_data **qd;
struct gfs2_quota_data **qd = qa->qa_qd;
int error; int error;
if (gfs2_assert_warn(sdp, !qa->qa_qd_num) || if (ip->i_res == NULL)
gfs2_rs_alloc(ip);
qd = ip->i_res->rs_qa_qd;
if (gfs2_assert_warn(sdp, !ip->i_res->rs_qa_qd_num) ||
gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)))
return -EIO; return -EIO;
...@@ -508,20 +512,20 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -508,20 +512,20 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd); error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd);
if (error) if (error)
goto out; goto out;
qa->qa_qd_num++; ip->i_res->rs_qa_qd_num++;
qd++; qd++;
error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd); error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd);
if (error) if (error)
goto out; goto out;
qa->qa_qd_num++; ip->i_res->rs_qa_qd_num++;
qd++; qd++;
if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
error = qdsb_get(sdp, QUOTA_USER, uid, qd); error = qdsb_get(sdp, QUOTA_USER, uid, qd);
if (error) if (error)
goto out; goto out;
qa->qa_qd_num++; ip->i_res->rs_qa_qd_num++;
qd++; qd++;
} }
...@@ -529,7 +533,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -529,7 +533,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
error = qdsb_get(sdp, QUOTA_GROUP, gid, qd); error = qdsb_get(sdp, QUOTA_GROUP, gid, qd);
if (error) if (error)
goto out; goto out;
qa->qa_qd_num++; ip->i_res->rs_qa_qd_num++;
qd++; qd++;
} }
...@@ -542,16 +546,17 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -542,16 +546,17 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
void gfs2_quota_unhold(struct gfs2_inode *ip) void gfs2_quota_unhold(struct gfs2_inode *ip)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_qadata *qa = ip->i_qadata;
unsigned int x; unsigned int x;
if (ip->i_res == NULL)
return;
gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags));
for (x = 0; x < qa->qa_qd_num; x++) { for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
qdsb_put(qa->qa_qd[x]); qdsb_put(ip->i_res->rs_qa_qd[x]);
qa->qa_qd[x] = NULL; ip->i_res->rs_qa_qd[x] = NULL;
} }
qa->qa_qd_num = 0; ip->i_res->rs_qa_qd_num = 0;
} }
static int sort_qd(const void *a, const void *b) static int sort_qd(const void *a, const void *b)
...@@ -764,6 +769,10 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) ...@@ -764,6 +769,10 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
unsigned int nalloc = 0, blocks; unsigned int nalloc = 0, blocks;
int error; int error;
error = gfs2_rs_alloc(ip);
if (error)
return error;
gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota),
&data_blocks, &ind_blocks); &data_blocks, &ind_blocks);
...@@ -915,7 +924,6 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, ...@@ -915,7 +924,6 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_qadata *qa = ip->i_qadata;
struct gfs2_quota_data *qd; struct gfs2_quota_data *qd;
unsigned int x; unsigned int x;
int error = 0; int error = 0;
...@@ -928,15 +936,15 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -928,15 +936,15 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
sdp->sd_args.ar_quota != GFS2_QUOTA_ON) sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
return 0; return 0;
sort(qa->qa_qd, qa->qa_qd_num, sizeof(struct gfs2_quota_data *), sort(ip->i_res->rs_qa_qd, ip->i_res->rs_qa_qd_num,
sort_qd, NULL); sizeof(struct gfs2_quota_data *), sort_qd, NULL);
for (x = 0; x < qa->qa_qd_num; x++) { for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
int force = NO_FORCE; int force = NO_FORCE;
qd = qa->qa_qd[x]; qd = ip->i_res->rs_qa_qd[x];
if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags))
force = FORCE; force = FORCE;
error = do_glock(qd, force, &qa->qa_qd_ghs[x]); error = do_glock(qd, force, &ip->i_res->rs_qa_qd_ghs[x]);
if (error) if (error)
break; break;
} }
...@@ -945,7 +953,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -945,7 +953,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
set_bit(GIF_QD_LOCKED, &ip->i_flags); set_bit(GIF_QD_LOCKED, &ip->i_flags);
else { else {
while (x--) while (x--)
gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); gfs2_glock_dq_uninit(&ip->i_res->rs_qa_qd_ghs[x]);
gfs2_quota_unhold(ip); gfs2_quota_unhold(ip);
} }
...@@ -990,7 +998,6 @@ static int need_sync(struct gfs2_quota_data *qd) ...@@ -990,7 +998,6 @@ static int need_sync(struct gfs2_quota_data *qd)
void gfs2_quota_unlock(struct gfs2_inode *ip) void gfs2_quota_unlock(struct gfs2_inode *ip)
{ {
struct gfs2_qadata *qa = ip->i_qadata;
struct gfs2_quota_data *qda[4]; struct gfs2_quota_data *qda[4];
unsigned int count = 0; unsigned int count = 0;
unsigned int x; unsigned int x;
...@@ -998,14 +1005,14 @@ void gfs2_quota_unlock(struct gfs2_inode *ip) ...@@ -998,14 +1005,14 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags)) if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags))
goto out; goto out;
for (x = 0; x < qa->qa_qd_num; x++) { for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
struct gfs2_quota_data *qd; struct gfs2_quota_data *qd;
int sync; int sync;
qd = qa->qa_qd[x]; qd = ip->i_res->rs_qa_qd[x];
sync = need_sync(qd); sync = need_sync(qd);
gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); gfs2_glock_dq_uninit(&ip->i_res->rs_qa_qd_ghs[x]);
if (sync && qd_trylock(qd)) if (sync && qd_trylock(qd))
qda[count++] = qd; qda[count++] = qd;
...@@ -1038,7 +1045,6 @@ static int print_message(struct gfs2_quota_data *qd, char *type) ...@@ -1038,7 +1045,6 @@ static int print_message(struct gfs2_quota_data *qd, char *type)
int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_qadata *qa = ip->i_qadata;
struct gfs2_quota_data *qd; struct gfs2_quota_data *qd;
s64 value; s64 value;
unsigned int x; unsigned int x;
...@@ -1050,8 +1056,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -1050,8 +1056,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
return 0; return 0;
for (x = 0; x < qa->qa_qd_num; x++) { for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
qd = qa->qa_qd[x]; qd = ip->i_res->rs_qa_qd[x];
if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) ||
(qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))))
...@@ -1089,7 +1095,6 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) ...@@ -1089,7 +1095,6 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
void gfs2_quota_change(struct gfs2_inode *ip, s64 change, void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
u32 uid, u32 gid) u32 uid, u32 gid)
{ {
struct gfs2_qadata *qa = ip->i_qadata;
struct gfs2_quota_data *qd; struct gfs2_quota_data *qd;
unsigned int x; unsigned int x;
...@@ -1098,8 +1103,8 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, ...@@ -1098,8 +1103,8 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
if (ip->i_diskflags & GFS2_DIF_SYSTEM) if (ip->i_diskflags & GFS2_DIF_SYSTEM)
return; return;
for (x = 0; x < qa->qa_qd_num; x++) { for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
qd = qa->qa_qd[x]; qd = ip->i_res->rs_qa_qd[x];
if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) ||
(qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) {
...@@ -1549,10 +1554,14 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, ...@@ -1549,10 +1554,14 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
if (error) if (error)
return error; return error;
error = gfs2_rs_alloc(ip);
if (error)
goto out_put;
mutex_lock(&ip->i_inode.i_mutex); mutex_lock(&ip->i_inode.i_mutex);
error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE, 0, &q_gh); error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE, 0, &q_gh);
if (error) if (error)
goto out_put; goto out_unlockput;
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
if (error) if (error)
goto out_q; goto out_q;
...@@ -1609,8 +1618,9 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, ...@@ -1609,8 +1618,9 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
gfs2_glock_dq_uninit(&i_gh); gfs2_glock_dq_uninit(&i_gh);
out_q: out_q:
gfs2_glock_dq_uninit(&q_gh); gfs2_glock_dq_uninit(&q_gh);
out_put: out_unlockput:
mutex_unlock(&ip->i_inode.i_mutex); mutex_unlock(&ip->i_inode.i_mutex);
out_put:
qd_put(qd); qd_put(qd);
return error; return error;
} }
......
This diff is collapsed.
...@@ -13,6 +13,14 @@ ...@@ -13,6 +13,14 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
/* Since each block in the file system is represented by two bits in the
* bitmap, one 64-bit word in the bitmap will represent 32 blocks.
* By reserving 32 blocks at a time, we can optimize / shortcut how we search
* through the bitmaps by looking a word at a time.
*/
#define RGRP_RSRV_MINBYTES 8
#define RGRP_RSRV_MINBLKS ((u32)(RGRP_RSRV_MINBYTES * GFS2_NBBY))
struct gfs2_rgrpd; struct gfs2_rgrpd;
struct gfs2_sbd; struct gfs2_sbd;
struct gfs2_holder; struct gfs2_holder;
...@@ -29,13 +37,7 @@ extern void gfs2_free_clones(struct gfs2_rgrpd *rgd); ...@@ -29,13 +37,7 @@ extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);
extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh);
extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh); extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh);
extern struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip); extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
static inline void gfs2_qadata_put(struct gfs2_inode *ip)
{
BUG_ON(ip->i_qadata == NULL);
kfree(ip->i_qadata);
ip->i_qadata = NULL;
}
extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested); extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested);
extern void gfs2_inplace_release(struct gfs2_inode *ip); extern void gfs2_inplace_release(struct gfs2_inode *ip);
...@@ -43,6 +45,9 @@ extern void gfs2_inplace_release(struct gfs2_inode *ip); ...@@ -43,6 +45,9 @@ extern void gfs2_inplace_release(struct gfs2_inode *ip);
extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
bool dinode, u64 *generation); bool dinode, u64 *generation);
extern int gfs2_rs_alloc(struct gfs2_inode *ip);
extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
extern void gfs2_rs_delete(struct gfs2_inode *ip);
extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta);
extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen);
extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
...@@ -68,4 +73,30 @@ extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset, ...@@ -68,4 +73,30 @@ extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed); const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);
extern int gfs2_fitrim(struct file *filp, void __user *argp); extern int gfs2_fitrim(struct file *filp, void __user *argp);
/* This is how to tell if a multi-block reservation is "inplace" reserved: */
static inline int gfs2_mb_reserved(struct gfs2_inode *ip)
{
if (ip->i_res && ip->i_res->rs_requested)
return 1;
return 0;
}
/* This is how to tell if a multi-block reservation is in the rgrp tree: */
static inline int gfs2_rs_active(struct gfs2_blkreserv *rs)
{
if (rs && rs->rs_bi)
return 1;
return 0;
}
static inline u32 gfs2_bi2rgd_blk(const struct gfs2_bitmap *bi, u32 blk)
{
return (bi->bi_start * GFS2_NBBY) + blk;
}
static inline u64 gfs2_rs_startblk(const struct gfs2_blkreserv *rs)
{
return gfs2_bi2rgd_blk(rs->rs_bi, rs->rs_biblk) + rs->rs_rgd->rd_data0;
}
#endif /* __RGRP_DOT_H__ */ #endif /* __RGRP_DOT_H__ */
...@@ -78,6 +78,8 @@ enum { ...@@ -78,6 +78,8 @@ enum {
Opt_quota_quantum, Opt_quota_quantum,
Opt_barrier, Opt_barrier,
Opt_nobarrier, Opt_nobarrier,
Opt_rgrplvb,
Opt_norgrplvb,
Opt_error, Opt_error,
}; };
...@@ -115,6 +117,8 @@ static const match_table_t tokens = { ...@@ -115,6 +117,8 @@ static const match_table_t tokens = {
{Opt_quota_quantum, "quota_quantum=%d"}, {Opt_quota_quantum, "quota_quantum=%d"},
{Opt_barrier, "barrier"}, {Opt_barrier, "barrier"},
{Opt_nobarrier, "nobarrier"}, {Opt_nobarrier, "nobarrier"},
{Opt_rgrplvb, "rgrplvb"},
{Opt_norgrplvb, "norgrplvb"},
{Opt_error, NULL} {Opt_error, NULL}
}; };
...@@ -267,6 +271,12 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) ...@@ -267,6 +271,12 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
case Opt_nobarrier: case Opt_nobarrier:
args->ar_nobarrier = 1; args->ar_nobarrier = 1;
break; break;
case Opt_rgrplvb:
args->ar_rgrplvb = 1;
break;
case Opt_norgrplvb:
args->ar_rgrplvb = 0;
break;
case Opt_error: case Opt_error:
default: default:
printk(KERN_WARNING "GFS2: invalid mount option: %s\n", o); printk(KERN_WARNING "GFS2: invalid mount option: %s\n", o);
...@@ -1381,6 +1391,8 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root) ...@@ -1381,6 +1391,8 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",nobarrier"); seq_printf(s, ",nobarrier");
if (test_bit(SDF_DEMOTE, &sdp->sd_flags)) if (test_bit(SDF_DEMOTE, &sdp->sd_flags))
seq_printf(s, ",demote_interface_used"); seq_printf(s, ",demote_interface_used");
if (args->ar_rgrplvb)
seq_printf(s, ",rgrplvb");
return 0; return 0;
} }
...@@ -1401,7 +1413,6 @@ static void gfs2_final_release_pages(struct gfs2_inode *ip) ...@@ -1401,7 +1413,6 @@ static void gfs2_final_release_pages(struct gfs2_inode *ip)
static int gfs2_dinode_dealloc(struct gfs2_inode *ip) static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_qadata *qa;
struct gfs2_rgrpd *rgd; struct gfs2_rgrpd *rgd;
struct gfs2_holder gh; struct gfs2_holder gh;
int error; int error;
...@@ -1411,13 +1422,13 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip) ...@@ -1411,13 +1422,13 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
return -EIO; return -EIO;
} }
qa = gfs2_qadata_get(ip); error = gfs2_rindex_update(sdp);
if (!qa) if (error)
return -ENOMEM; return error;
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
goto out; return error;
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1); rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
if (!rgd) { if (!rgd) {
...@@ -1445,8 +1456,6 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip) ...@@ -1445,8 +1456,6 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
gfs2_glock_dq_uninit(&gh); gfs2_glock_dq_uninit(&gh);
out_qs: out_qs:
gfs2_quota_unhold(ip); gfs2_quota_unhold(ip);
out:
gfs2_qadata_put(ip);
return error; return error;
} }
...@@ -1547,6 +1556,9 @@ static void gfs2_evict_inode(struct inode *inode) ...@@ -1547,6 +1556,9 @@ static void gfs2_evict_inode(struct inode *inode)
out_unlock: out_unlock:
/* Error path for case 1 */ /* Error path for case 1 */
if (gfs2_rs_active(ip->i_res))
gfs2_rs_deltree(ip->i_res);
if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags))
gfs2_glock_dq(&ip->i_iopen_gh); gfs2_glock_dq(&ip->i_iopen_gh);
gfs2_holder_uninit(&ip->i_iopen_gh); gfs2_holder_uninit(&ip->i_iopen_gh);
...@@ -1556,6 +1568,7 @@ static void gfs2_evict_inode(struct inode *inode) ...@@ -1556,6 +1568,7 @@ static void gfs2_evict_inode(struct inode *inode)
out: out:
/* Case 3 starts here */ /* Case 3 starts here */
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
gfs2_rs_delete(ip);
clear_inode(inode); clear_inode(inode);
gfs2_dir_hash_inval(ip); gfs2_dir_hash_inval(ip);
ip->i_gl->gl_object = NULL; ip->i_gl->gl_object = NULL;
...@@ -1578,6 +1591,7 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) ...@@ -1578,6 +1591,7 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
ip->i_flags = 0; ip->i_flags = 0;
ip->i_gl = NULL; ip->i_gl = NULL;
ip->i_rgd = NULL; ip->i_rgd = NULL;
ip->i_res = NULL;
} }
return &ip->i_inode; return &ip->i_inode;
} }
......
...@@ -276,7 +276,15 @@ static struct attribute *gfs2_attrs[] = { ...@@ -276,7 +276,15 @@ static struct attribute *gfs2_attrs[] = {
NULL, NULL,
}; };
static void gfs2_sbd_release(struct kobject *kobj)
{
struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
kfree(sdp);
}
static struct kobj_type gfs2_ktype = { static struct kobj_type gfs2_ktype = {
.release = gfs2_sbd_release,
.default_attrs = gfs2_attrs, .default_attrs = gfs2_attrs,
.sysfs_ops = &gfs2_attr_ops, .sysfs_ops = &gfs2_attr_ops,
}; };
...@@ -583,6 +591,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) ...@@ -583,6 +591,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
char ro[20]; char ro[20];
char spectator[20]; char spectator[20];
char *envp[] = { ro, spectator, NULL }; char *envp[] = { ro, spectator, NULL };
int sysfs_frees_sdp = 0;
sprintf(ro, "RDONLY=%d", (sb->s_flags & MS_RDONLY) ? 1 : 0); sprintf(ro, "RDONLY=%d", (sb->s_flags & MS_RDONLY) ? 1 : 0);
sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0);
...@@ -591,8 +600,10 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) ...@@ -591,8 +600,10 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL,
"%s", sdp->sd_table_name); "%s", sdp->sd_table_name);
if (error) if (error)
goto fail; goto fail_reg;
sysfs_frees_sdp = 1; /* Freeing sdp is now done by sysfs calling
function gfs2_sbd_release. */
error = sysfs_create_group(&sdp->sd_kobj, &tune_group); error = sysfs_create_group(&sdp->sd_kobj, &tune_group);
if (error) if (error)
goto fail_reg; goto fail_reg;
...@@ -615,9 +626,13 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) ...@@ -615,9 +626,13 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
fail_tune: fail_tune:
sysfs_remove_group(&sdp->sd_kobj, &tune_group); sysfs_remove_group(&sdp->sd_kobj, &tune_group);
fail_reg: fail_reg:
kobject_put(&sdp->sd_kobj); free_percpu(sdp->sd_lkstats);
fail:
fs_err(sdp, "error %d adding sysfs files", error); fs_err(sdp, "error %d adding sysfs files", error);
if (sysfs_frees_sdp)
kobject_put(&sdp->sd_kobj);
else
kfree(sdp);
sb->s_fs_info = NULL;
return error; return error;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/ktime.h> #include <linux/ktime.h>
#include "incore.h" #include "incore.h"
#include "glock.h" #include "glock.h"
#include "rgrp.h"
#define dlm_state_name(nn) { DLM_LOCK_##nn, #nn } #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
#define glock_trace_name(x) __print_symbolic(x, \ #define glock_trace_name(x) __print_symbolic(x, \
...@@ -31,6 +32,17 @@ ...@@ -31,6 +32,17 @@
{ GFS2_BLKST_DINODE, "dinode" }, \ { GFS2_BLKST_DINODE, "dinode" }, \
{ GFS2_BLKST_UNLINKED, "unlinked" }) { GFS2_BLKST_UNLINKED, "unlinked" })
#define TRACE_RS_DELETE 0
#define TRACE_RS_TREEDEL 1
#define TRACE_RS_INSERT 2
#define TRACE_RS_CLAIM 3
#define rs_func_name(x) __print_symbolic(x, \
{ 0, "del " }, \
{ 1, "tdel" }, \
{ 2, "ins " }, \
{ 3, "clm " })
#define show_glock_flags(flags) __print_flags(flags, "", \ #define show_glock_flags(flags) __print_flags(flags, "", \
{(1UL << GLF_LOCK), "l" }, \ {(1UL << GLF_LOCK), "l" }, \
{(1UL << GLF_DEMOTE), "D" }, \ {(1UL << GLF_DEMOTE), "D" }, \
...@@ -470,6 +482,7 @@ TRACE_EVENT(gfs2_block_alloc, ...@@ -470,6 +482,7 @@ TRACE_EVENT(gfs2_block_alloc,
__field( u8, block_state ) __field( u8, block_state )
__field( u64, rd_addr ) __field( u64, rd_addr )
__field( u32, rd_free_clone ) __field( u32, rd_free_clone )
__field( u32, rd_reserved )
), ),
TP_fast_assign( TP_fast_assign(
...@@ -480,16 +493,58 @@ TRACE_EVENT(gfs2_block_alloc, ...@@ -480,16 +493,58 @@ TRACE_EVENT(gfs2_block_alloc,
__entry->block_state = block_state; __entry->block_state = block_state;
__entry->rd_addr = rgd->rd_addr; __entry->rd_addr = rgd->rd_addr;
__entry->rd_free_clone = rgd->rd_free_clone; __entry->rd_free_clone = rgd->rd_free_clone;
__entry->rd_reserved = rgd->rd_reserved;
), ),
TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u", TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
MAJOR(__entry->dev), MINOR(__entry->dev), MAJOR(__entry->dev), MINOR(__entry->dev),
(unsigned long long)__entry->inum, (unsigned long long)__entry->inum,
(unsigned long long)__entry->start, (unsigned long long)__entry->start,
(unsigned long)__entry->len, (unsigned long)__entry->len,
block_state_name(__entry->block_state), block_state_name(__entry->block_state),
(unsigned long long)__entry->rd_addr, (unsigned long long)__entry->rd_addr,
__entry->rd_free_clone) __entry->rd_free_clone, (unsigned long)__entry->rd_reserved)
);
/* Keep track of multi-block reservations as they are allocated/freed */
TRACE_EVENT(gfs2_rs,
TP_PROTO(const struct gfs2_inode *ip, const struct gfs2_blkreserv *rs,
u8 func),
TP_ARGS(ip, rs, func),
TP_STRUCT__entry(
__field( dev_t, dev )
__field( u64, rd_addr )
__field( u32, rd_free_clone )
__field( u32, rd_reserved )
__field( u64, inum )
__field( u64, start )
__field( u32, free )
__field( u8, func )
),
TP_fast_assign(
__entry->dev = rs->rs_rgd ? rs->rs_rgd->rd_sbd->sd_vfs->s_dev : 0;
__entry->rd_addr = rs->rs_rgd ? rs->rs_rgd->rd_addr : 0;
__entry->rd_free_clone = rs->rs_rgd ? rs->rs_rgd->rd_free_clone : 0;
__entry->rd_reserved = rs->rs_rgd ? rs->rs_rgd->rd_reserved : 0;
__entry->inum = ip ? ip->i_no_addr : 0;
__entry->start = gfs2_rs_startblk(rs);
__entry->free = rs->rs_free;
__entry->func = func;
),
TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s "
"f:%lu",
MAJOR(__entry->dev), MINOR(__entry->dev),
(unsigned long long)__entry->inum,
(unsigned long long)__entry->start,
(unsigned long long)__entry->rd_addr,
(unsigned long)__entry->rd_free_clone,
(unsigned long)__entry->rd_reserved,
rs_func_name(__entry->func), (unsigned long)__entry->free)
); );
#endif /* _TRACE_GFS2_H */ #endif /* _TRACE_GFS2_H */
......
...@@ -31,7 +31,7 @@ struct gfs2_glock; ...@@ -31,7 +31,7 @@ struct gfs2_glock;
static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip) static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip)
{ {
const struct gfs2_blkreserv *rs = ip->i_res; const struct gfs2_blkreserv *rs = ip->i_res;
if (rs->rs_requested < ip->i_rgd->rd_length) if (rs && rs->rs_requested < ip->i_rgd->rd_length)
return rs->rs_requested + 1; return rs->rs_requested + 1;
return ip->i_rgd->rd_length; return ip->i_rgd->rd_length;
} }
......
...@@ -79,23 +79,19 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -79,23 +79,19 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
const char *type, const char *function, const char *type, const char *function,
char *file, unsigned int line); char *file, unsigned int line);
static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp, static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
struct buffer_head *bh, struct buffer_head *bh)
const char *function,
char *file, unsigned int line)
{ {
struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
u32 magic = be32_to_cpu(mh->mh_magic); u32 magic = be32_to_cpu(mh->mh_magic);
if (unlikely(magic != GFS2_MAGIC)) if (unlikely(magic != GFS2_MAGIC)) {
return gfs2_meta_check_ii(sdp, bh, "magic number", function, printk(KERN_ERR "GFS2: Magic number missing at %llu\n",
file, line); (unsigned long long)bh->b_blocknr);
return -EIO;
}
return 0; return 0;
} }
#define gfs2_meta_check(sdp, bh) \
gfs2_meta_check_i((sdp), (bh), __func__, __FILE__, __LINE__)
int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
u16 type, u16 t, u16 type, u16 t,
const char *function, const char *function,
......
...@@ -325,12 +325,11 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, ...@@ -325,12 +325,11 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
struct gfs2_ea_header *ea, struct gfs2_ea_header *ea,
struct gfs2_ea_header *prev, int leave) struct gfs2_ea_header *prev, int leave)
{ {
struct gfs2_qadata *qa;
int error; int error;
qa = gfs2_qadata_get(ip); error = gfs2_rindex_update(GFS2_SB(&ip->i_inode));
if (!qa) if (error)
return -ENOMEM; return error;
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
...@@ -340,7 +339,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, ...@@ -340,7 +339,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
gfs2_quota_unhold(ip); gfs2_quota_unhold(ip);
out_alloc: out_alloc:
gfs2_qadata_put(ip);
return error; return error;
} }
...@@ -713,17 +711,16 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, ...@@ -713,17 +711,16 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
unsigned int blks, unsigned int blks,
ea_skeleton_call_t skeleton_call, void *private) ea_skeleton_call_t skeleton_call, void *private)
{ {
struct gfs2_qadata *qa;
struct buffer_head *dibh; struct buffer_head *dibh;
int error; int error;
qa = gfs2_qadata_get(ip); error = gfs2_rindex_update(GFS2_SB(&ip->i_inode));
if (!qa) if (error)
return -ENOMEM; return error;
error = gfs2_quota_lock_check(ip); error = gfs2_quota_lock_check(ip);
if (error) if (error)
goto out; return error;
error = gfs2_inplace_reserve(ip, blks); error = gfs2_inplace_reserve(ip, blks);
if (error) if (error)
...@@ -753,8 +750,6 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, ...@@ -753,8 +750,6 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
gfs2_inplace_release(ip); gfs2_inplace_release(ip);
out_gunlock_q: out_gunlock_q:
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
out:
gfs2_qadata_put(ip);
return error; return error;
} }
...@@ -1494,16 +1489,15 @@ static int ea_dealloc_block(struct gfs2_inode *ip) ...@@ -1494,16 +1489,15 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
int gfs2_ea_dealloc(struct gfs2_inode *ip) int gfs2_ea_dealloc(struct gfs2_inode *ip)
{ {
struct gfs2_qadata *qa;
int error; int error;
qa = gfs2_qadata_get(ip); error = gfs2_rindex_update(GFS2_SB(&ip->i_inode));
if (!qa) if (error)
return -ENOMEM; return error;
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
if (error) if (error)
goto out_alloc; return error;
error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); error = ea_foreach(ip, ea_dealloc_unstuffed, NULL);
if (error) if (error)
...@@ -1519,8 +1513,6 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip) ...@@ -1519,8 +1513,6 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
out_quota: out_quota:
gfs2_quota_unhold(ip); gfs2_quota_unhold(ip);
out_alloc:
gfs2_qadata_put(ip);
return error; return error;
} }
......
...@@ -385,15 +385,12 @@ int seq_escape(struct seq_file *m, const char *s, const char *esc) ...@@ -385,15 +385,12 @@ int seq_escape(struct seq_file *m, const char *s, const char *esc)
} }
EXPORT_SYMBOL(seq_escape); EXPORT_SYMBOL(seq_escape);
int seq_printf(struct seq_file *m, const char *f, ...) int seq_vprintf(struct seq_file *m, const char *f, va_list args)
{ {
va_list args;
int len; int len;
if (m->count < m->size) { if (m->count < m->size) {
va_start(args, f);
len = vsnprintf(m->buf + m->count, m->size - m->count, f, args); len = vsnprintf(m->buf + m->count, m->size - m->count, f, args);
va_end(args);
if (m->count + len < m->size) { if (m->count + len < m->size) {
m->count += len; m->count += len;
return 0; return 0;
...@@ -402,6 +399,19 @@ int seq_printf(struct seq_file *m, const char *f, ...) ...@@ -402,6 +399,19 @@ int seq_printf(struct seq_file *m, const char *f, ...)
seq_set_overflow(m); seq_set_overflow(m);
return -1; return -1;
} }
EXPORT_SYMBOL(seq_vprintf);
int seq_printf(struct seq_file *m, const char *f, ...)
{
int ret;
va_list args;
va_start(args, f);
ret = seq_vprintf(m, f, args);
va_end(args);
return ret;
}
EXPORT_SYMBOL(seq_printf); EXPORT_SYMBOL(seq_printf);
/** /**
......
...@@ -170,6 +170,16 @@ struct gfs2_rindex { ...@@ -170,6 +170,16 @@ struct gfs2_rindex {
#define GFS2_RGF_NOALLOC 0x00000008 #define GFS2_RGF_NOALLOC 0x00000008
#define GFS2_RGF_TRIMMED 0x00000010 #define GFS2_RGF_TRIMMED 0x00000010
struct gfs2_rgrp_lvb {
__be32 rl_magic;
__be32 rl_flags;
__be32 rl_free;
__be32 rl_dinodes;
__be64 rl_igeneration;
__be32 rl_unlinked;
__be32 __pad;
};
struct gfs2_rgrp { struct gfs2_rgrp {
struct gfs2_meta_header rg_header; struct gfs2_meta_header rg_header;
...@@ -214,6 +224,7 @@ enum { ...@@ -214,6 +224,7 @@ enum {
gfs2fl_NoAtime = 7, gfs2fl_NoAtime = 7,
gfs2fl_Sync = 8, gfs2fl_Sync = 8,
gfs2fl_System = 9, gfs2fl_System = 9,
gfs2fl_TopLevel = 10,
gfs2fl_TruncInProg = 29, gfs2fl_TruncInProg = 29,
gfs2fl_InheritDirectio = 30, gfs2fl_InheritDirectio = 30,
gfs2fl_InheritJdata = 31, gfs2fl_InheritJdata = 31,
...@@ -230,8 +241,9 @@ enum { ...@@ -230,8 +241,9 @@ enum {
#define GFS2_DIF_NOATIME 0x00000080 #define GFS2_DIF_NOATIME 0x00000080
#define GFS2_DIF_SYNC 0x00000100 #define GFS2_DIF_SYNC 0x00000100
#define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */ #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
#define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
#define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */ #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
#define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
#define GFS2_DIF_INHERIT_JDATA 0x80000000 #define GFS2_DIF_INHERIT_JDATA 0x80000000
struct gfs2_dinode { struct gfs2_dinode {
......
...@@ -86,6 +86,7 @@ int seq_puts(struct seq_file *m, const char *s); ...@@ -86,6 +86,7 @@ int seq_puts(struct seq_file *m, const char *s);
int seq_write(struct seq_file *seq, const void *data, size_t len); int seq_write(struct seq_file *seq, const void *data, size_t len);
__printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); __printf(2, 3) int seq_printf(struct seq_file *, const char *, ...);
__printf(2, 0) int seq_vprintf(struct seq_file *, const char *, va_list args);
int seq_path(struct seq_file *, const struct path *, const char *); int seq_path(struct seq_file *, const struct path *, const char *);
int seq_dentry(struct seq_file *, struct dentry *, const char *); int seq_dentry(struct seq_file *, struct dentry *, const char *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment