Commit 49302baa authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw

* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw:
  GFS2: combine duplicated block freeing routines
  GFS2: Add S_NOSEC support
  GFS2: Automatically adjust glock min hold time
  GFS2: Cache dir hash table in a contiguous buffer
parents eadc3875 46fcb2ed
...@@ -854,11 +854,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, ...@@ -854,11 +854,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
blen++; blen++;
else { else {
if (bstart) { if (bstart) {
if (metadata) __gfs2_free_blocks(ip, bstart, blen, metadata);
__gfs2_free_meta(ip, bstart, blen);
else
__gfs2_free_data(ip, bstart, blen);
btotal += blen; btotal += blen;
} }
...@@ -870,11 +866,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, ...@@ -870,11 +866,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
gfs2_add_inode_blocks(&ip->i_inode, -1); gfs2_add_inode_blocks(&ip->i_inode, -1);
} }
if (bstart) { if (bstart) {
if (metadata) __gfs2_free_blocks(ip, bstart, blen, metadata);
__gfs2_free_meta(ip, bstart, blen);
else
__gfs2_free_data(ip, bstart, blen);
btotal += blen; btotal += blen;
} }
......
...@@ -339,6 +339,67 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset, ...@@ -339,6 +339,67 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
return (copied) ? copied : error; return (copied) ? copied : error;
} }
/**
* gfs2_dir_get_hash_table - Get pointer to the dir hash table
* @ip: The inode in question
*
* Returns: The hash table or an error
*/
static __be64 *gfs2_dir_get_hash_table(struct gfs2_inode *ip)
{
struct inode *inode = &ip->i_inode;
int ret;
u32 hsize;
__be64 *hc;
BUG_ON(!(ip->i_diskflags & GFS2_DIF_EXHASH));
hc = ip->i_hash_cache;
if (hc)
return hc;
hsize = 1 << ip->i_depth;
hsize *= sizeof(__be64);
if (hsize != i_size_read(&ip->i_inode)) {
gfs2_consist_inode(ip);
return ERR_PTR(-EIO);
}
hc = kmalloc(hsize, GFP_NOFS);
ret = -ENOMEM;
if (hc == NULL)
return ERR_PTR(-ENOMEM);
ret = gfs2_dir_read_data(ip, (char *)hc, 0, hsize, 1);
if (ret < 0) {
kfree(hc);
return ERR_PTR(ret);
}
spin_lock(&inode->i_lock);
if (ip->i_hash_cache)
kfree(hc);
else
ip->i_hash_cache = hc;
spin_unlock(&inode->i_lock);
return ip->i_hash_cache;
}
/**
* gfs2_dir_hash_inval - Invalidate dir hash
* @ip: The directory inode
*
* Must be called with an exclusive glock, or during glock invalidation.
*/
void gfs2_dir_hash_inval(struct gfs2_inode *ip)
{
__be64 *hc = ip->i_hash_cache;
ip->i_hash_cache = NULL;
kfree(hc);
}
static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent) static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent)
{ {
return dent->de_inum.no_addr == 0 || dent->de_inum.no_formal_ino == 0; return dent->de_inum.no_addr == 0 || dent->de_inum.no_formal_ino == 0;
...@@ -686,17 +747,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no, ...@@ -686,17 +747,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
static int get_leaf_nr(struct gfs2_inode *dip, u32 index, static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
u64 *leaf_out) u64 *leaf_out)
{ {
__be64 leaf_no; __be64 *hash;
int error;
error = gfs2_dir_read_data(dip, (char *)&leaf_no,
index * sizeof(__be64),
sizeof(__be64), 0);
if (error != sizeof(u64))
return (error < 0) ? error : -EIO;
*leaf_out = be64_to_cpu(leaf_no);
hash = gfs2_dir_get_hash_table(dip);
if (IS_ERR(hash))
return PTR_ERR(hash);
*leaf_out = be64_to_cpu(*(hash + index));
return 0; return 0;
} }
...@@ -966,6 +1022,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) ...@@ -966,6 +1022,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
for (x = 0; x < half_len; x++) for (x = 0; x < half_len; x++)
lp[x] = cpu_to_be64(bn); lp[x] = cpu_to_be64(bn);
gfs2_dir_hash_inval(dip);
error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(u64), error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(u64),
half_len * sizeof(u64)); half_len * sizeof(u64));
if (error != half_len * sizeof(u64)) { if (error != half_len * sizeof(u64)) {
...@@ -1052,70 +1110,54 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) ...@@ -1052,70 +1110,54 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
static int dir_double_exhash(struct gfs2_inode *dip) static int dir_double_exhash(struct gfs2_inode *dip)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
struct buffer_head *dibh; struct buffer_head *dibh;
u32 hsize; u32 hsize;
u64 *buf; u32 hsize_bytes;
u64 *from, *to; __be64 *hc;
u64 block; __be64 *hc2, *h;
u64 disksize = i_size_read(&dip->i_inode);
int x; int x;
int error = 0; int error = 0;
hsize = 1 << dip->i_depth; hsize = 1 << dip->i_depth;
if (hsize * sizeof(u64) != disksize) { hsize_bytes = hsize * sizeof(__be64);
gfs2_consist_inode(dip);
return -EIO;
}
/* Allocate both the "from" and "to" buffers in one big chunk */ hc = gfs2_dir_get_hash_table(dip);
if (IS_ERR(hc))
return PTR_ERR(hc);
buf = kcalloc(3, sdp->sd_hash_bsize, GFP_NOFS); h = hc2 = kmalloc(hsize_bytes * 2, GFP_NOFS);
if (!buf) if (!hc2)
return -ENOMEM; return -ENOMEM;
for (block = disksize >> sdp->sd_hash_bsize_shift; block--;) { error = gfs2_meta_inode_buffer(dip, &dibh);
error = gfs2_dir_read_data(dip, (char *)buf, if (error)
block * sdp->sd_hash_bsize, goto out_kfree;
sdp->sd_hash_bsize, 1);
if (error != sdp->sd_hash_bsize) {
if (error >= 0)
error = -EIO;
goto fail;
}
from = buf;
to = (u64 *)((char *)buf + sdp->sd_hash_bsize);
for (x = sdp->sd_hash_ptrs; x--; from++) {
*to++ = *from; /* No endianess worries */
*to++ = *from;
}
error = gfs2_dir_write_data(dip, for (x = 0; x < hsize; x++) {
(char *)buf + sdp->sd_hash_bsize, *h++ = *hc;
block * sdp->sd_sb.sb_bsize, *h++ = *hc;
sdp->sd_sb.sb_bsize); hc++;
if (error != sdp->sd_sb.sb_bsize) {
if (error >= 0)
error = -EIO;
goto fail;
}
} }
kfree(buf); error = gfs2_dir_write_data(dip, (char *)hc2, 0, hsize_bytes * 2);
if (error != (hsize_bytes * 2))
error = gfs2_meta_inode_buffer(dip, &dibh); goto fail;
if (!gfs2_assert_withdraw(sdp, !error)) {
dip->i_depth++;
gfs2_dinode_out(dip, dibh->b_data);
brelse(dibh);
}
return error; gfs2_dir_hash_inval(dip);
dip->i_hash_cache = hc2;
dip->i_depth++;
gfs2_dinode_out(dip, dibh->b_data);
brelse(dibh);
return 0;
fail: fail:
kfree(buf); /* Replace original hash table & size */
gfs2_dir_write_data(dip, (char *)hc, 0, hsize_bytes);
i_size_write(&dip->i_inode, hsize_bytes);
gfs2_dinode_out(dip, dibh->b_data);
brelse(dibh);
out_kfree:
kfree(hc2);
return error; return error;
} }
...@@ -1348,6 +1390,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, ...@@ -1348,6 +1390,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
return error; return error;
} }
/** /**
* dir_e_read - Reads the entries from a directory into a filldir buffer * dir_e_read - Reads the entries from a directory into a filldir buffer
* @dip: dinode pointer * @dip: dinode pointer
...@@ -1362,9 +1405,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1362,9 +1405,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
filldir_t filldir) filldir_t filldir)
{ {
struct gfs2_inode *dip = GFS2_I(inode); struct gfs2_inode *dip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
u32 hsize, len = 0; u32 hsize, len = 0;
u32 ht_offset, lp_offset, ht_offset_cur = -1;
u32 hash, index; u32 hash, index;
__be64 *lp; __be64 *lp;
int copied = 0; int copied = 0;
...@@ -1372,37 +1413,17 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1372,37 +1413,17 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
unsigned depth = 0; unsigned depth = 0;
hsize = 1 << dip->i_depth; hsize = 1 << dip->i_depth;
if (hsize * sizeof(u64) != i_size_read(inode)) {
gfs2_consist_inode(dip);
return -EIO;
}
hash = gfs2_dir_offset2hash(*offset); hash = gfs2_dir_offset2hash(*offset);
index = hash >> (32 - dip->i_depth); index = hash >> (32 - dip->i_depth);
lp = kmalloc(sdp->sd_hash_bsize, GFP_NOFS); lp = gfs2_dir_get_hash_table(dip);
if (!lp) if (IS_ERR(lp))
return -ENOMEM; return PTR_ERR(lp);
while (index < hsize) { while (index < hsize) {
lp_offset = index & (sdp->sd_hash_ptrs - 1);
ht_offset = index - lp_offset;
if (ht_offset_cur != ht_offset) {
error = gfs2_dir_read_data(dip, (char *)lp,
ht_offset * sizeof(__be64),
sdp->sd_hash_bsize, 1);
if (error != sdp->sd_hash_bsize) {
if (error >= 0)
error = -EIO;
goto out;
}
ht_offset_cur = ht_offset;
}
error = gfs2_dir_read_leaf(inode, offset, opaque, filldir, error = gfs2_dir_read_leaf(inode, offset, opaque, filldir,
&copied, &depth, &copied, &depth,
be64_to_cpu(lp[lp_offset])); be64_to_cpu(lp[index]));
if (error) if (error)
break; break;
...@@ -1410,8 +1431,6 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1410,8 +1431,6 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
index = (index & ~(len - 1)) + len; index = (index & ~(len - 1)) + len;
} }
out:
kfree(lp);
if (error > 0) if (error > 0)
error = 0; error = 0;
return error; return error;
...@@ -1914,43 +1933,22 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, ...@@ -1914,43 +1933,22 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip) int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
struct buffer_head *bh; struct buffer_head *bh;
struct gfs2_leaf *leaf; struct gfs2_leaf *leaf;
u32 hsize, len; u32 hsize, len;
u32 ht_offset, lp_offset, ht_offset_cur = -1;
u32 index = 0, next_index; u32 index = 0, next_index;
__be64 *lp; __be64 *lp;
u64 leaf_no; u64 leaf_no;
int error = 0, last; int error = 0, last;
hsize = 1 << dip->i_depth; hsize = 1 << dip->i_depth;
if (hsize * sizeof(u64) != i_size_read(&dip->i_inode)) {
gfs2_consist_inode(dip);
return -EIO;
}
lp = kmalloc(sdp->sd_hash_bsize, GFP_NOFS); lp = gfs2_dir_get_hash_table(dip);
if (!lp) if (IS_ERR(lp))
return -ENOMEM; return PTR_ERR(lp);
while (index < hsize) { while (index < hsize) {
lp_offset = index & (sdp->sd_hash_ptrs - 1); leaf_no = be64_to_cpu(lp[index]);
ht_offset = index - lp_offset;
if (ht_offset_cur != ht_offset) {
error = gfs2_dir_read_data(dip, (char *)lp,
ht_offset * sizeof(__be64),
sdp->sd_hash_bsize, 1);
if (error != sdp->sd_hash_bsize) {
if (error >= 0)
error = -EIO;
goto out;
}
ht_offset_cur = ht_offset;
}
leaf_no = be64_to_cpu(lp[lp_offset]);
if (leaf_no) { if (leaf_no) {
error = get_leaf(dip, leaf_no, &bh); error = get_leaf(dip, leaf_no, &bh);
if (error) if (error)
...@@ -1976,7 +1974,6 @@ int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip) ...@@ -1976,7 +1974,6 @@ int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip)
} }
out: out:
kfree(lp);
return error; return error;
} }
......
...@@ -35,6 +35,7 @@ extern int gfs2_diradd_alloc_required(struct inode *dir, ...@@ -35,6 +35,7 @@ extern int gfs2_diradd_alloc_required(struct inode *dir,
const struct qstr *filename); const struct qstr *filename);
extern int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block, extern int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block,
struct buffer_head **bhp); struct buffer_head **bhp);
extern void gfs2_dir_hash_inval(struct gfs2_inode *ip);
static inline u32 gfs2_disk_hash(const char *data, int len) static inline u32 gfs2_disk_hash(const char *data, int len)
{ {
......
...@@ -174,7 +174,9 @@ void gfs2_set_inode_flags(struct inode *inode) ...@@ -174,7 +174,9 @@ void gfs2_set_inode_flags(struct inode *inode)
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
unsigned int flags = inode->i_flags; unsigned int flags = inode->i_flags;
flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
inode->i_flags |= S_NOSEC;
if (ip->i_diskflags & GFS2_DIF_IMMUTABLE) if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
flags |= S_IMMUTABLE; flags |= S_IMMUTABLE;
if (ip->i_diskflags & GFS2_DIF_APPENDONLY) if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
......
...@@ -409,6 +409,10 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state) ...@@ -409,6 +409,10 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
if (held1 && held2 && list_empty(&gl->gl_holders)) if (held1 && held2 && list_empty(&gl->gl_holders))
clear_bit(GLF_QUEUED, &gl->gl_flags); clear_bit(GLF_QUEUED, &gl->gl_flags);
if (new_state != gl->gl_target)
/* shorten our minimum hold time */
gl->gl_hold_time = max(gl->gl_hold_time - GL_GLOCK_HOLD_DECR,
GL_GLOCK_MIN_HOLD);
gl->gl_state = new_state; gl->gl_state = new_state;
gl->gl_tchange = jiffies; gl->gl_tchange = jiffies;
} }
...@@ -668,7 +672,7 @@ static void glock_work_func(struct work_struct *work) ...@@ -668,7 +672,7 @@ static void glock_work_func(struct work_struct *work)
gl->gl_demote_state != LM_ST_EXCLUSIVE) { gl->gl_demote_state != LM_ST_EXCLUSIVE) {
unsigned long holdtime, now = jiffies; unsigned long holdtime, now = jiffies;
holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; holdtime = gl->gl_tchange + gl->gl_hold_time;
if (time_before(now, holdtime)) if (time_before(now, holdtime))
delay = holdtime - now; delay = holdtime - now;
...@@ -679,9 +683,14 @@ static void glock_work_func(struct work_struct *work) ...@@ -679,9 +683,14 @@ static void glock_work_func(struct work_struct *work)
} }
run_queue(gl, 0); run_queue(gl, 0);
spin_unlock(&gl->gl_spin); spin_unlock(&gl->gl_spin);
if (!delay || if (!delay)
queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
gfs2_glock_put(gl); gfs2_glock_put(gl);
else {
if (gl->gl_name.ln_type != LM_TYPE_INODE)
delay = 0;
if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
gfs2_glock_put(gl);
}
if (drop_ref) if (drop_ref)
gfs2_glock_put(gl); gfs2_glock_put(gl);
} }
...@@ -743,6 +752,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, ...@@ -743,6 +752,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
gl->gl_tchange = jiffies; gl->gl_tchange = jiffies;
gl->gl_object = NULL; gl->gl_object = NULL;
gl->gl_sbd = sdp; gl->gl_sbd = sdp;
gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
INIT_DELAYED_WORK(&gl->gl_work, glock_work_func); INIT_DELAYED_WORK(&gl->gl_work, glock_work_func);
INIT_WORK(&gl->gl_delete, delete_work_func); INIT_WORK(&gl->gl_delete, delete_work_func);
...@@ -855,8 +865,15 @@ static int gfs2_glock_demote_wait(void *word) ...@@ -855,8 +865,15 @@ static int gfs2_glock_demote_wait(void *word)
static void wait_on_holder(struct gfs2_holder *gh) static void wait_on_holder(struct gfs2_holder *gh)
{ {
unsigned long time1 = jiffies;
might_sleep(); might_sleep();
wait_on_bit(&gh->gh_iflags, HIF_WAIT, gfs2_glock_holder_wait, TASK_UNINTERRUPTIBLE); wait_on_bit(&gh->gh_iflags, HIF_WAIT, gfs2_glock_holder_wait, TASK_UNINTERRUPTIBLE);
if (time_after(jiffies, time1 + HZ)) /* have we waited > a second? */
/* Lengthen the minimum hold time. */
gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time +
GL_GLOCK_HOLD_INCR,
GL_GLOCK_MAX_HOLD);
} }
static void wait_on_demote(struct gfs2_glock *gl) static void wait_on_demote(struct gfs2_glock *gl)
...@@ -1093,8 +1110,9 @@ void gfs2_glock_dq(struct gfs2_holder *gh) ...@@ -1093,8 +1110,9 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
gfs2_glock_hold(gl); gfs2_glock_hold(gl);
if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) && if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
!test_bit(GLF_DEMOTE, &gl->gl_flags)) !test_bit(GLF_DEMOTE, &gl->gl_flags) &&
delay = gl->gl_ops->go_min_hold_time; gl->gl_name.ln_type == LM_TYPE_INODE)
delay = gl->gl_hold_time;
if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0) if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
gfs2_glock_put(gl); gfs2_glock_put(gl);
} }
...@@ -1273,12 +1291,13 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state) ...@@ -1273,12 +1291,13 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
unsigned long now = jiffies; unsigned long now = jiffies;
gfs2_glock_hold(gl); gfs2_glock_hold(gl);
holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; holdtime = gl->gl_tchange + gl->gl_hold_time;
if (test_bit(GLF_QUEUED, &gl->gl_flags)) { if (test_bit(GLF_QUEUED, &gl->gl_flags) &&
gl->gl_name.ln_type == LM_TYPE_INODE) {
if (time_before(now, holdtime)) if (time_before(now, holdtime))
delay = holdtime - now; delay = holdtime - now;
if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags)) if (test_bit(GLF_REPLY_PENDING, &gl->gl_flags))
delay = gl->gl_ops->go_min_hold_time; delay = gl->gl_hold_time;
} }
spin_lock(&gl->gl_spin); spin_lock(&gl->gl_spin);
...@@ -1667,7 +1686,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl) ...@@ -1667,7 +1686,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
dtime *= 1000000/HZ; /* demote time in uSec */ dtime *= 1000000/HZ; /* demote time in uSec */
if (!test_bit(GLF_DEMOTE, &gl->gl_flags)) if (!test_bit(GLF_DEMOTE, &gl->gl_flags))
dtime = 0; dtime = 0;
gfs2_print_dbg(seq, "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d v:%d r:%d\n", gfs2_print_dbg(seq, "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d v:%d r:%d m:%ld\n",
state2str(gl->gl_state), state2str(gl->gl_state),
gl->gl_name.ln_type, gl->gl_name.ln_type,
(unsigned long long)gl->gl_name.ln_number, (unsigned long long)gl->gl_name.ln_number,
...@@ -1676,7 +1695,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl) ...@@ -1676,7 +1695,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
state2str(gl->gl_demote_state), dtime, state2str(gl->gl_demote_state), dtime,
atomic_read(&gl->gl_ail_count), atomic_read(&gl->gl_ail_count),
atomic_read(&gl->gl_revokes), atomic_read(&gl->gl_revokes),
atomic_read(&gl->gl_ref)); atomic_read(&gl->gl_ref), gl->gl_hold_time);
list_for_each_entry(gh, &gl->gl_holders, gh_list) { list_for_each_entry(gh, &gl->gl_holders, gh_list) {
error = dump_holder(seq, gh); error = dump_holder(seq, gh);
......
...@@ -113,6 +113,12 @@ enum { ...@@ -113,6 +113,12 @@ enum {
#define GLR_TRYFAILED 13 #define GLR_TRYFAILED 13
#define GL_GLOCK_MAX_HOLD (long)(HZ / 5)
#define GL_GLOCK_DFT_HOLD (long)(HZ / 5)
#define GL_GLOCK_MIN_HOLD (long)(10)
#define GL_GLOCK_HOLD_INCR (long)(HZ / 20)
#define GL_GLOCK_HOLD_DECR (long)(HZ / 40)
struct lm_lockops { struct lm_lockops {
const char *lm_proto_name; const char *lm_proto_name;
int (*lm_mount) (struct gfs2_sbd *sdp, const char *fsname); int (*lm_mount) (struct gfs2_sbd *sdp, const char *fsname);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "rgrp.h" #include "rgrp.h"
#include "util.h" #include "util.h"
#include "trans.h" #include "trans.h"
#include "dir.h"
/** /**
* __gfs2_ail_flush - remove all buffers for a given lock from the AIL * __gfs2_ail_flush - remove all buffers for a given lock from the AIL
...@@ -218,6 +219,7 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags) ...@@ -218,6 +219,7 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
if (ip) { if (ip) {
set_bit(GIF_INVALID, &ip->i_flags); set_bit(GIF_INVALID, &ip->i_flags);
forget_all_cached_acls(&ip->i_inode); forget_all_cached_acls(&ip->i_inode);
gfs2_dir_hash_inval(ip);
} }
} }
...@@ -316,6 +318,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ...@@ -316,6 +318,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
ip->i_generation = be64_to_cpu(str->di_generation); ip->i_generation = be64_to_cpu(str->di_generation);
ip->i_diskflags = be32_to_cpu(str->di_flags); ip->i_diskflags = be32_to_cpu(str->di_flags);
ip->i_eattr = be64_to_cpu(str->di_eattr);
/* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
gfs2_set_inode_flags(&ip->i_inode); gfs2_set_inode_flags(&ip->i_inode);
height = be16_to_cpu(str->di_height); height = be16_to_cpu(str->di_height);
if (unlikely(height > GFS2_MAX_META_HEIGHT)) if (unlikely(height > GFS2_MAX_META_HEIGHT))
...@@ -328,7 +332,6 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ...@@ -328,7 +332,6 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
ip->i_depth = (u8)depth; ip->i_depth = (u8)depth;
ip->i_entries = be32_to_cpu(str->di_entries); ip->i_entries = be32_to_cpu(str->di_entries);
ip->i_eattr = be64_to_cpu(str->di_eattr);
if (S_ISREG(ip->i_inode.i_mode)) if (S_ISREG(ip->i_inode.i_mode))
gfs2_set_aops(&ip->i_inode); gfs2_set_aops(&ip->i_inode);
...@@ -549,7 +552,6 @@ const struct gfs2_glock_operations gfs2_inode_glops = { ...@@ -549,7 +552,6 @@ const struct gfs2_glock_operations gfs2_inode_glops = {
.go_lock = inode_go_lock, .go_lock = inode_go_lock,
.go_dump = inode_go_dump, .go_dump = inode_go_dump,
.go_type = LM_TYPE_INODE, .go_type = LM_TYPE_INODE,
.go_min_hold_time = HZ / 5,
.go_flags = GLOF_ASPACE, .go_flags = GLOF_ASPACE,
}; };
...@@ -560,7 +562,6 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = { ...@@ -560,7 +562,6 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
.go_unlock = rgrp_go_unlock, .go_unlock = rgrp_go_unlock,
.go_dump = gfs2_rgrp_dump, .go_dump = gfs2_rgrp_dump,
.go_type = LM_TYPE_RGRP, .go_type = LM_TYPE_RGRP,
.go_min_hold_time = HZ / 5,
.go_flags = GLOF_ASPACE, .go_flags = GLOF_ASPACE,
}; };
......
...@@ -163,7 +163,6 @@ struct gfs2_glock_operations { ...@@ -163,7 +163,6 @@ struct gfs2_glock_operations {
int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl); int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
void (*go_callback) (struct gfs2_glock *gl); void (*go_callback) (struct gfs2_glock *gl);
const int go_type; const int go_type;
const unsigned long go_min_hold_time;
const unsigned long go_flags; const unsigned long go_flags;
#define GLOF_ASPACE 1 #define GLOF_ASPACE 1
}; };
...@@ -221,6 +220,7 @@ struct gfs2_glock { ...@@ -221,6 +220,7 @@ struct gfs2_glock {
unsigned int gl_hash; unsigned int gl_hash;
unsigned long gl_demote_time; /* time of first demote request */ unsigned long gl_demote_time; /* time of first demote request */
long gl_hold_time;
struct list_head gl_holders; struct list_head gl_holders;
const struct gfs2_glock_operations *gl_ops; const struct gfs2_glock_operations *gl_ops;
...@@ -285,6 +285,7 @@ struct gfs2_inode { ...@@ -285,6 +285,7 @@ struct gfs2_inode {
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;
struct list_head i_trunc_list; struct list_head i_trunc_list;
__be64 *i_hash_cache;
u32 i_entries; u32 i_entries;
u32 i_diskflags; u32 i_diskflags;
u8 i_height; u8 i_height;
......
...@@ -41,6 +41,7 @@ static void gfs2_init_inode_once(void *foo) ...@@ -41,6 +41,7 @@ static void gfs2_init_inode_once(void *foo)
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_alloc = NULL; ip->i_alloc = NULL;
ip->i_hash_cache = NULL;
} }
static void gfs2_init_glock_once(void *foo) static void gfs2_init_glock_once(void *foo)
......
...@@ -1094,6 +1094,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent ...@@ -1094,6 +1094,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
if (sdp->sd_args.ar_nobarrier) if (sdp->sd_args.ar_nobarrier)
set_bit(SDF_NOBARRIERS, &sdp->sd_flags); set_bit(SDF_NOBARRIERS, &sdp->sd_flags);
sb->s_flags |= MS_NOSEC;
sb->s_magic = GFS2_MAGIC; sb->s_magic = GFS2_MAGIC;
sb->s_op = &gfs2_super_ops; sb->s_op = &gfs2_super_ops;
sb->s_d_op = &gfs2_dops; sb->s_d_op = &gfs2_dops;
......
...@@ -1607,14 +1607,15 @@ int gfs2_alloc_di(struct gfs2_inode *dip, u64 *bn, u64 *generation) ...@@ -1607,14 +1607,15 @@ int gfs2_alloc_di(struct gfs2_inode *dip, u64 *bn, u64 *generation)
} }
/** /**
* gfs2_free_data - free a contiguous run of data block(s) * __gfs2_free_blocks - free a contiguous run of block(s)
* @ip: the inode these blocks are being freed from * @ip: the inode these blocks are being freed from
* @bstart: first block of a run of contiguous blocks * @bstart: first block of a run of contiguous blocks
* @blen: the length of the block run * @blen: the length of the block run
* @meta: 1 if the blocks represent metadata
* *
*/ */
void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_rgrpd *rgd; struct gfs2_rgrpd *rgd;
...@@ -1631,53 +1632,10 @@ void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) ...@@ -1631,53 +1632,10 @@ void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
gfs2_trans_add_rg(rgd); gfs2_trans_add_rg(rgd);
/* Directories keep their data in the metadata address space */ /* Directories keep their data in the metadata address space */
if (ip->i_depth) if (meta || ip->i_depth)
gfs2_meta_wipe(ip, bstart, blen); gfs2_meta_wipe(ip, bstart, blen);
} }
/**
* gfs2_free_data - free a contiguous run of data block(s)
* @ip: the inode these blocks are being freed from
* @bstart: first block of a run of contiguous blocks
* @blen: the length of the block run
*
*/
void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
{
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
__gfs2_free_data(ip, bstart, blen);
gfs2_statfs_change(sdp, 0, +blen, 0);
gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
}
/**
* gfs2_free_meta - free a contiguous run of data block(s)
* @ip: the inode these blocks are being freed from
* @bstart: first block of a run of contiguous blocks
* @blen: the length of the block run
*
*/
void __gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
{
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_rgrpd *rgd;
rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE);
if (!rgd)
return;
trace_gfs2_block_alloc(ip, bstart, blen, GFS2_BLKST_FREE);
rgd->rd_free += blen;
gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
gfs2_trans_add_rg(rgd);
gfs2_meta_wipe(ip, bstart, blen);
}
/** /**
* gfs2_free_meta - free a contiguous run of data block(s) * gfs2_free_meta - free a contiguous run of data block(s)
* @ip: the inode these blocks are being freed from * @ip: the inode these blocks are being freed from
...@@ -1690,7 +1648,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen) ...@@ -1690,7 +1648,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
__gfs2_free_meta(ip, bstart, blen); __gfs2_free_blocks(ip, bstart, blen, 1);
gfs2_statfs_change(sdp, 0, +blen, 0); gfs2_statfs_change(sdp, 0, +blen, 0);
gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid); gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
} }
......
...@@ -52,9 +52,7 @@ extern int gfs2_ri_update(struct gfs2_inode *ip); ...@@ -52,9 +52,7 @@ extern int gfs2_ri_update(struct gfs2_inode *ip);
extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n); extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n);
extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation); extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation);
extern void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen); extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta);
extern void gfs2_free_data(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_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);
extern void gfs2_unlink_di(struct inode *inode); extern void gfs2_unlink_di(struct inode *inode);
......
...@@ -1533,7 +1533,7 @@ static void gfs2_evict_inode(struct inode *inode) ...@@ -1533,7 +1533,7 @@ static void gfs2_evict_inode(struct inode *inode)
/* Case 3 starts here */ /* Case 3 starts here */
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode); end_writeback(inode);
gfs2_dir_hash_inval(ip);
ip->i_gl->gl_object = NULL; ip->i_gl->gl_object = NULL;
gfs2_glock_add_to_lru(ip->i_gl); gfs2_glock_add_to_lru(ip->i_gl);
gfs2_glock_put(ip->i_gl); gfs2_glock_put(ip->i_gl);
......
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