Skip to content

Commit 4850f52

Browse files
committed
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: print glock numbers in hex GFS2: ordered writes are backwards GFS2: Remove old, unused linked list code from quota GFS2: Remove loopy umount code GFS2: Metadata address space clean up
2 parents 3ff1562 + 4818972 commit 4850f52

17 files changed

Lines changed: 109 additions & 164 deletions

File tree

‎fs/gfs2/aops.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,8 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
10611061

10621062
int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
10631063
{
1064-
struct inode *aspace = page->mapping->host;
1065-
struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info;
1064+
struct address_space *mapping = page->mapping;
1065+
struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
10661066
struct buffer_head *bh, *head;
10671067
struct gfs2_bufdata *bd;
10681068

‎fs/gfs2/glock.c‎

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/list.h>
2020
#include <linux/wait.h>
2121
#include <linux/module.h>
22-
#include <linux/rwsem.h>
2322
#include <asm/uaccess.h>
2423
#include <linux/seq_file.h>
2524
#include <linux/debugfs.h>
@@ -60,7 +59,6 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
6059
#define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { __dump_glock(NULL, gl); BUG(); } } while(0)
6160
static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
6261

63-
static DECLARE_RWSEM(gfs2_umount_flush_sem);
6462
static struct dentry *gfs2_root;
6563
static struct workqueue_struct *glock_workqueue;
6664
struct workqueue_struct *gfs2_delete_workqueue;
@@ -154,12 +152,14 @@ static unsigned int gl_hash(const struct gfs2_sbd *sdp,
154152
static void glock_free(struct gfs2_glock *gl)
155153
{
156154
struct gfs2_sbd *sdp = gl->gl_sbd;
157-
struct inode *aspace = gl->gl_aspace;
155+
struct address_space *mapping = gfs2_glock2aspace(gl);
156+
struct kmem_cache *cachep = gfs2_glock_cachep;
158157

159-
if (aspace)
160-
gfs2_aspace_put(aspace);
158+
GLOCK_BUG_ON(gl, mapping && mapping->nrpages);
161159
trace_gfs2_glock_put(gl);
162-
sdp->sd_lockstruct.ls_ops->lm_put_lock(gfs2_glock_cachep, gl);
160+
if (mapping)
161+
cachep = gfs2_glock_aspace_cachep;
162+
sdp->sd_lockstruct.ls_ops->lm_put_lock(cachep, gl);
163163
}
164164

165165
/**
@@ -712,7 +712,6 @@ static void glock_work_func(struct work_struct *work)
712712
finish_xmote(gl, gl->gl_reply);
713713
drop_ref = 1;
714714
}
715-
down_read(&gfs2_umount_flush_sem);
716715
spin_lock(&gl->gl_spin);
717716
if (test_and_clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
718717
gl->gl_state != LM_ST_UNLOCKED &&
@@ -725,7 +724,6 @@ static void glock_work_func(struct work_struct *work)
725724
}
726725
run_queue(gl, 0);
727726
spin_unlock(&gl->gl_spin);
728-
up_read(&gfs2_umount_flush_sem);
729727
if (!delay ||
730728
queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
731729
gfs2_glock_put(gl);
@@ -750,10 +748,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
750748
const struct gfs2_glock_operations *glops, int create,
751749
struct gfs2_glock **glp)
752750
{
751+
struct super_block *s = sdp->sd_vfs;
753752
struct lm_lockname name = { .ln_number = number, .ln_type = glops->go_type };
754753
struct gfs2_glock *gl, *tmp;
755754
unsigned int hash = gl_hash(sdp, &name);
756-
int error;
755+
struct address_space *mapping;
757756

758757
read_lock(gl_lock_addr(hash));
759758
gl = search_bucket(hash, sdp, &name);
@@ -765,7 +764,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
765764
if (!create)
766765
return -ENOENT;
767766

768-
gl = kmem_cache_alloc(gfs2_glock_cachep, GFP_KERNEL);
767+
if (glops->go_flags & GLOF_ASPACE)
768+
gl = kmem_cache_alloc(gfs2_glock_aspace_cachep, GFP_KERNEL);
769+
else
770+
gl = kmem_cache_alloc(gfs2_glock_cachep, GFP_KERNEL);
769771
if (!gl)
770772
return -ENOMEM;
771773

@@ -784,18 +786,18 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
784786
gl->gl_tchange = jiffies;
785787
gl->gl_object = NULL;
786788
gl->gl_sbd = sdp;
787-
gl->gl_aspace = NULL;
788789
INIT_DELAYED_WORK(&gl->gl_work, glock_work_func);
789790
INIT_WORK(&gl->gl_delete, delete_work_func);
790791

791-
/* If this glock protects actual on-disk data or metadata blocks,
792-
create a VFS inode to manage the pages/buffers holding them. */
793-
if (glops == &gfs2_inode_glops || glops == &gfs2_rgrp_glops) {
794-
gl->gl_aspace = gfs2_aspace_get(sdp);
795-
if (!gl->gl_aspace) {
796-
error = -ENOMEM;
797-
goto fail;
798-
}
792+
mapping = gfs2_glock2aspace(gl);
793+
if (mapping) {
794+
mapping->a_ops = &gfs2_meta_aops;
795+
mapping->host = s->s_bdev->bd_inode;
796+
mapping->flags = 0;
797+
mapping_set_gfp_mask(mapping, GFP_NOFS);
798+
mapping->assoc_mapping = NULL;
799+
mapping->backing_dev_info = s->s_bdi;
800+
mapping->writeback_index = 0;
799801
}
800802

801803
write_lock(gl_lock_addr(hash));
@@ -812,10 +814,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
812814
*glp = gl;
813815

814816
return 0;
815-
816-
fail:
817-
kmem_cache_free(gfs2_glock_cachep, gl);
818-
return error;
819817
}
820818

821819
/**
@@ -1510,35 +1508,10 @@ void gfs2_glock_thaw(struct gfs2_sbd *sdp)
15101508

15111509
void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
15121510
{
1513-
unsigned long t;
15141511
unsigned int x;
1515-
int cont;
15161512

1517-
t = jiffies;
1518-
1519-
for (;;) {
1520-
cont = 0;
1521-
for (x = 0; x < GFS2_GL_HASH_SIZE; x++) {
1522-
if (examine_bucket(clear_glock, sdp, x))
1523-
cont = 1;
1524-
}
1525-
1526-
if (!cont)
1527-
break;
1528-
1529-
if (time_after_eq(jiffies,
1530-
t + gfs2_tune_get(sdp, gt_stall_secs) * HZ)) {
1531-
fs_warn(sdp, "Unmount seems to be stalled. "
1532-
"Dumping lock state...\n");
1533-
gfs2_dump_lockstate(sdp);
1534-
t = jiffies;
1535-
}
1536-
1537-
down_write(&gfs2_umount_flush_sem);
1538-
invalidate_inodes(sdp->sd_vfs);
1539-
up_write(&gfs2_umount_flush_sem);
1540-
msleep(10);
1541-
}
1513+
for (x = 0; x < GFS2_GL_HASH_SIZE; x++)
1514+
examine_bucket(clear_glock, sdp, x);
15421515
flush_workqueue(glock_workqueue);
15431516
wait_event(sdp->sd_glock_wait, atomic_read(&sdp->sd_glock_disposal) == 0);
15441517
gfs2_dump_lockstate(sdp);
@@ -1685,7 +1658,7 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
16851658
dtime *= 1000000/HZ; /* demote time in uSec */
16861659
if (!test_bit(GLF_DEMOTE, &gl->gl_flags))
16871660
dtime = 0;
1688-
gfs2_print_dbg(seq, "G: s:%s n:%u/%llu f:%s t:%s d:%s/%llu a:%d r:%d\n",
1661+
gfs2_print_dbg(seq, "G: s:%s n:%u/%llx f:%s t:%s d:%s/%llu a:%d r:%d\n",
16891662
state2str(gl->gl_state),
16901663
gl->gl_name.ln_type,
16911664
(unsigned long long)gl->gl_name.ln_number,

‎fs/gfs2/glock.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ static inline int gfs2_glock_is_held_shrd(struct gfs2_glock *gl)
180180
return gl->gl_state == LM_ST_SHARED;
181181
}
182182

183+
static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl)
184+
{
185+
if (gl->gl_ops->go_flags & GLOF_ASPACE)
186+
return (struct address_space *)(gl + 1);
187+
return NULL;
188+
}
189+
183190
int gfs2_glock_get(struct gfs2_sbd *sdp,
184191
u64 number, const struct gfs2_glock_operations *glops,
185192
int create, struct gfs2_glock **glp);

‎fs/gfs2/glops.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
8787

8888
static void rgrp_go_sync(struct gfs2_glock *gl)
8989
{
90-
struct address_space *metamapping = gl->gl_aspace->i_mapping;
90+
struct address_space *metamapping = gfs2_glock2aspace(gl);
9191
int error;
9292

9393
if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
@@ -113,7 +113,7 @@ static void rgrp_go_sync(struct gfs2_glock *gl)
113113

114114
static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
115115
{
116-
struct address_space *mapping = gl->gl_aspace->i_mapping;
116+
struct address_space *mapping = gfs2_glock2aspace(gl);
117117

118118
BUG_ON(!(flags & DIO_METADATA));
119119
gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
@@ -134,7 +134,7 @@ static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
134134
static void inode_go_sync(struct gfs2_glock *gl)
135135
{
136136
struct gfs2_inode *ip = gl->gl_object;
137-
struct address_space *metamapping = gl->gl_aspace->i_mapping;
137+
struct address_space *metamapping = gfs2_glock2aspace(gl);
138138
int error;
139139

140140
if (ip && !S_ISREG(ip->i_inode.i_mode))
@@ -183,7 +183,7 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
183183
gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
184184

185185
if (flags & DIO_METADATA) {
186-
struct address_space *mapping = gl->gl_aspace->i_mapping;
186+
struct address_space *mapping = gfs2_glock2aspace(gl);
187187
truncate_inode_pages(mapping, 0);
188188
if (ip) {
189189
set_bit(GIF_INVALID, &ip->i_flags);
@@ -282,7 +282,8 @@ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
282282

283283
static int rgrp_go_demote_ok(const struct gfs2_glock *gl)
284284
{
285-
return !gl->gl_aspace->i_mapping->nrpages;
285+
const struct address_space *mapping = (const struct address_space *)(gl + 1);
286+
return !mapping->nrpages;
286287
}
287288

288289
/**
@@ -387,8 +388,7 @@ static void iopen_go_callback(struct gfs2_glock *gl)
387388
struct gfs2_inode *ip = (struct gfs2_inode *)gl->gl_object;
388389

389390
if (gl->gl_demote_state == LM_ST_UNLOCKED &&
390-
gl->gl_state == LM_ST_SHARED &&
391-
ip && test_bit(GIF_USER, &ip->i_flags)) {
391+
gl->gl_state == LM_ST_SHARED && ip) {
392392
gfs2_glock_hold(gl);
393393
if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
394394
gfs2_glock_put_nolock(gl);
@@ -407,6 +407,7 @@ const struct gfs2_glock_operations gfs2_inode_glops = {
407407
.go_dump = inode_go_dump,
408408
.go_type = LM_TYPE_INODE,
409409
.go_min_hold_time = HZ / 5,
410+
.go_flags = GLOF_ASPACE,
410411
};
411412

412413
const struct gfs2_glock_operations gfs2_rgrp_glops = {
@@ -418,6 +419,7 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
418419
.go_dump = gfs2_rgrp_dump,
419420
.go_type = LM_TYPE_RGRP,
420421
.go_min_hold_time = HZ / 5,
422+
.go_flags = GLOF_ASPACE,
421423
};
422424

423425
const struct gfs2_glock_operations gfs2_trans_glops = {

‎fs/gfs2/incore.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ struct gfs2_glock_operations {
162162
void (*go_callback) (struct gfs2_glock *gl);
163163
const int go_type;
164164
const unsigned long go_min_hold_time;
165+
const unsigned long go_flags;
166+
#define GLOF_ASPACE 1
165167
};
166168

167169
enum {
@@ -225,7 +227,6 @@ struct gfs2_glock {
225227

226228
struct gfs2_sbd *gl_sbd;
227229

228-
struct inode *gl_aspace;
229230
struct list_head gl_ail_list;
230231
atomic_t gl_ail_count;
231232
struct delayed_work gl_work;
@@ -258,7 +259,6 @@ enum {
258259
GIF_INVALID = 0,
259260
GIF_QD_LOCKED = 1,
260261
GIF_SW_PAGED = 3,
261-
GIF_USER = 4, /* user inode, not metadata addr space */
262262
};
263263

264264

@@ -451,7 +451,6 @@ struct gfs2_tune {
451451
unsigned int gt_quota_quantum; /* Secs between syncs to quota file */
452452
unsigned int gt_new_files_jdata;
453453
unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */
454-
unsigned int gt_stall_secs; /* Detects trouble! */
455454
unsigned int gt_complain_secs;
456455
unsigned int gt_statfs_quantum;
457456
unsigned int gt_statfs_slow;

‎fs/gfs2/inode.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int iget_test(struct inode *inode, void *opaque)
4545
struct gfs2_inode *ip = GFS2_I(inode);
4646
u64 *no_addr = opaque;
4747

48-
if (ip->i_no_addr == *no_addr && test_bit(GIF_USER, &ip->i_flags))
48+
if (ip->i_no_addr == *no_addr)
4949
return 1;
5050

5151
return 0;
@@ -58,7 +58,6 @@ static int iget_set(struct inode *inode, void *opaque)
5858

5959
inode->i_ino = (unsigned long)*no_addr;
6060
ip->i_no_addr = *no_addr;
61-
set_bit(GIF_USER, &ip->i_flags);
6261
return 0;
6362
}
6463

@@ -84,7 +83,7 @@ static int iget_skip_test(struct inode *inode, void *opaque)
8483
struct gfs2_inode *ip = GFS2_I(inode);
8584
struct gfs2_skip_data *data = opaque;
8685

87-
if (ip->i_no_addr == data->no_addr && test_bit(GIF_USER, &ip->i_flags)){
86+
if (ip->i_no_addr == data->no_addr) {
8887
if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)){
8988
data->skipped = 1;
9089
return 0;
@@ -103,7 +102,6 @@ static int iget_skip_set(struct inode *inode, void *opaque)
103102
return 1;
104103
inode->i_ino = (unsigned long)(data->no_addr);
105104
ip->i_no_addr = data->no_addr;
106-
set_bit(GIF_USER, &ip->i_flags);
107105
return 0;
108106
}
109107

‎fs/gfs2/lock_dlm.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ static void gdlm_ast(void *arg)
3030

3131
switch (gl->gl_lksb.sb_status) {
3232
case -DLM_EUNLOCK: /* Unlocked, so glock can be freed */
33-
kmem_cache_free(gfs2_glock_cachep, gl);
33+
if (gl->gl_ops->go_flags & GLOF_ASPACE)
34+
kmem_cache_free(gfs2_glock_aspace_cachep, gl);
35+
else
36+
kmem_cache_free(gfs2_glock_cachep, gl);
3437
if (atomic_dec_and_test(&sdp->sd_glock_disposal))
3538
wake_up(&sdp->sd_glock_wait);
3639
return;

‎fs/gfs2/lops.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
528528
gfs2_pin(sdp, bd->bd_bh);
529529
tr->tr_num_databuf_new++;
530530
sdp->sd_log_num_databuf++;
531-
list_add(&le->le_list, &sdp->sd_log_le_databuf);
531+
list_add_tail(&le->le_list, &sdp->sd_log_le_databuf);
532532
} else {
533-
list_add(&le->le_list, &sdp->sd_log_le_ordered);
533+
list_add_tail(&le->le_list, &sdp->sd_log_le_ordered);
534534
}
535535
out:
536536
gfs2_log_unlock(sdp);

0 commit comments

Comments
 (0)