* [Cluster-devel] [PATCH] GFS2: Addendum patch 2 for gfs2_grow @ 2007-05-14 17:42 Robert Peterson 2007-05-15 8:48 ` Steven Whitehouse 0 siblings, 1 reply; 3+ messages in thread From: Robert Peterson @ 2007-05-14 17:42 UTC (permalink / raw) To: cluster-devel.redhat.com This addendum patch 2 corrects three things: 1. It fixes a stupid mistake in the previous addendum that broke gfs2. Ref: https://www.redhat.com/archives/cluster-devel/2007-May/msg00162.html 2. It fixes a problem that Dave Teigland pointed out regarding the external declarations in ops_address.h being in the wrong place. 3. It recasts a couple more %llu printks to (unsigned long long) as requested by Steve Whitehouse. I would have loved to put this all in one revised patch, but there was a rush to get some patches for RHEL5. Therefore, the previous patches were applied to the git tree "as is" and therefore, I'm posting another addendum. Sorry. This patch is to be applied to today's rebased 2.6.22-rc1 kernel git tree. Signed-off-by: Bob Peterson <rpeterso@redhat.com> -- fs/gfs2/glock.c | 7 ++++--- fs/gfs2/ops_address.c | 1 + fs/gfs2/ops_address.h | 3 --- fs/gfs2/rgrp.c | 6 +++--- fs/gfs2/rgrp.h | 1 + 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1815429..c66c718 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1823,7 +1823,8 @@ static int dump_inode(struct glock_iter *gi, struct gfs2_inode *ip) print_dbg(gi, " Inode:\n"); print_dbg(gi, " num = %llu/%llu\n", - ip->i_num.no_formal_ino, ip->i_num.no_addr); + (unsigned long long)ip->i_num.no_formal_ino, + (unsigned long long)ip->i_num.no_addr); print_dbg(gi, " type = %u\n", IF2DT(ip->i_inode.i_mode)); print_dbg(gi, " i_flags ="); for (x = 0; x < 32; x++) @@ -1909,8 +1910,8 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl) } if (test_bit(GLF_DEMOTE, &gl->gl_flags)) { print_dbg(gi, " Demotion req to state %u (%llu uS ago)\n", - gl->gl_demote_state, - (u64)(jiffies - gl->gl_demote_time)*(1000000/HZ)); + gl->gl_demote_state, (unsigned long long) + (jiffies - gl->gl_demote_time)*(1000000/HZ)); } if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) { if (!test_bit(GLF_LOCK, &gl->gl_flags) && diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index e0b4e8c..4913ef5 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -32,6 +32,7 @@ #include "trans.h" #include "rgrp.h" #include "ops_file.h" +#include "super.h" #include "util.h" #include "glops.h" diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h index 56c30da..fa1b5b3 100644 --- a/fs/gfs2/ops_address.h +++ b/fs/gfs2/ops_address.h @@ -18,8 +18,5 @@ extern const struct address_space_operations gfs2_file_aops; extern int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create); extern int gfs2_releasepage(struct page *page, gfp_t gfp_mask); -extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); -extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, - s64 dinodes); #endif /* __OPS_ADDRESS_DOT_H__ */ diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 48a6461..a62c0f2 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -527,10 +527,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *inode = &ip->i_inode; struct file_ra_state ra_state; - u64 junk = ip->i_di.di_size; + u64 rgrp_count = ip->i_di.di_size; int error; - if (do_div(junk, sizeof(struct gfs2_rindex))) { + if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { gfs2_consist_inode(ip); return -EIO; } @@ -538,7 +538,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) clear_rgrpdi(sdp); file_ra_state_init(&ra_state, inode->i_mapping); - for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { + for (sdp->sd_rgrps = 0; sdp->sd_rgrps < rgrp_count; sdp->sd_rgrps++) { error = read_rindex_entry(ip, &ra_state); if (error) { clear_rgrpdi(sdp); diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index b01e0cf..b4c6adf 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -65,5 +65,6 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state, int flags); void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); +u64 gfs2_ri_total(struct gfs2_sbd *sdp); #endif /* __RGRP_DOT_H__ */ ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] GFS2: Addendum patch 2 for gfs2_grow 2007-05-14 17:42 [Cluster-devel] [PATCH] GFS2: Addendum patch 2 for gfs2_grow Robert Peterson @ 2007-05-15 8:48 ` Steven Whitehouse 0 siblings, 0 replies; 3+ messages in thread From: Steven Whitehouse @ 2007-05-15 8:48 UTC (permalink / raw) To: cluster-devel.redhat.com Hi, Now in the -nmw git tree. Thanks, Steve. On Mon, 2007-05-14 at 12:42 -0500, Robert Peterson wrote: > This addendum patch 2 corrects three things: > > 1. It fixes a stupid mistake in the previous addendum that broke gfs2. > Ref: https://www.redhat.com/archives/cluster-devel/2007-May/msg00162.html > 2. It fixes a problem that Dave Teigland pointed out regarding the > external declarations in ops_address.h being in the wrong place. > 3. It recasts a couple more %llu printks to (unsigned long long) > as requested by Steve Whitehouse. > > I would have loved to put this all in one revised patch, but there was > a rush to get some patches for RHEL5. Therefore, the previous patches > were applied to the git tree "as is" and therefore, I'm posting another > addendum. Sorry. > > This patch is to be applied to today's rebased 2.6.22-rc1 kernel git tree. > > Signed-off-by: Bob Peterson <rpeterso@redhat.com> > -- > fs/gfs2/glock.c | 7 ++++--- > fs/gfs2/ops_address.c | 1 + > fs/gfs2/ops_address.h | 3 --- > fs/gfs2/rgrp.c | 6 +++--- > fs/gfs2/rgrp.h | 1 + > 5 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c > index 1815429..c66c718 100644 > --- a/fs/gfs2/glock.c > +++ b/fs/gfs2/glock.c > @@ -1823,7 +1823,8 @@ static int dump_inode(struct glock_iter *gi, struct gfs2_inode *ip) > > print_dbg(gi, " Inode:\n"); > print_dbg(gi, " num = %llu/%llu\n", > - ip->i_num.no_formal_ino, ip->i_num.no_addr); > + (unsigned long long)ip->i_num.no_formal_ino, > + (unsigned long long)ip->i_num.no_addr); > print_dbg(gi, " type = %u\n", IF2DT(ip->i_inode.i_mode)); > print_dbg(gi, " i_flags ="); > for (x = 0; x < 32; x++) > @@ -1909,8 +1910,8 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl) > } > if (test_bit(GLF_DEMOTE, &gl->gl_flags)) { > print_dbg(gi, " Demotion req to state %u (%llu uS ago)\n", > - gl->gl_demote_state, > - (u64)(jiffies - gl->gl_demote_time)*(1000000/HZ)); > + gl->gl_demote_state, (unsigned long long) > + (jiffies - gl->gl_demote_time)*(1000000/HZ)); > } > if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) { > if (!test_bit(GLF_LOCK, &gl->gl_flags) && > diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c > index e0b4e8c..4913ef5 100644 > --- a/fs/gfs2/ops_address.c > +++ b/fs/gfs2/ops_address.c > @@ -32,6 +32,7 @@ > #include "trans.h" > #include "rgrp.h" > #include "ops_file.h" > +#include "super.h" > #include "util.h" > #include "glops.h" > > diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h > index 56c30da..fa1b5b3 100644 > --- a/fs/gfs2/ops_address.h > +++ b/fs/gfs2/ops_address.h > @@ -18,8 +18,5 @@ extern const struct address_space_operations gfs2_file_aops; > extern int gfs2_get_block(struct inode *inode, sector_t lblock, > struct buffer_head *bh_result, int create); > extern int gfs2_releasepage(struct page *page, gfp_t gfp_mask); > -extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); > -extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, > - s64 dinodes); > > #endif /* __OPS_ADDRESS_DOT_H__ */ > diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c > index 48a6461..a62c0f2 100644 > --- a/fs/gfs2/rgrp.c > +++ b/fs/gfs2/rgrp.c > @@ -527,10 +527,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip) > struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); > struct inode *inode = &ip->i_inode; > struct file_ra_state ra_state; > - u64 junk = ip->i_di.di_size; > + u64 rgrp_count = ip->i_di.di_size; > int error; > > - if (do_div(junk, sizeof(struct gfs2_rindex))) { > + if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { > gfs2_consist_inode(ip); > return -EIO; > } > @@ -538,7 +538,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) > clear_rgrpdi(sdp); > > file_ra_state_init(&ra_state, inode->i_mapping); > - for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { > + for (sdp->sd_rgrps = 0; sdp->sd_rgrps < rgrp_count; sdp->sd_rgrps++) { > error = read_rindex_entry(ip, &ra_state); > if (error) { > clear_rgrpdi(sdp); > diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h > index b01e0cf..b4c6adf 100644 > --- a/fs/gfs2/rgrp.h > +++ b/fs/gfs2/rgrp.h > @@ -65,5 +65,6 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, > void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state, > int flags); > void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); > +u64 gfs2_ri_total(struct gfs2_sbd *sdp); > > #endif /* __RGRP_DOT_H__ */ > ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cluster-devel] [GFS2/DLM] Pre-pull Patch Posting @ 2007-07-09 16:02 swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] flush the glock completely in inode_go_sync swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com Hi, This is the current set of patches from the GFS2/DLM -nmw git tree which are pending inclusion in the current merge window. There are quite a few mainly as I was a bit lazy in pushing some of the smaller bug fixes before. There are a couple of things in -mm which depend upon changes in the current GFS2 tree, so my plan is to request a merge very shortly to leave time for those other items to be merged later. All the changes here only relate to GFS2 and/or DLM, there are no changes which affect any of the core code. Most of the patches are in fatc bug fixes and/or cleanups. The only "new" feature is GFS2 is the nanosecond timestamps feature. Steve. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [GFS2] flush the glock completely in inode_go_sync 2007-07-09 16:02 [Cluster-devel] [GFS2/DLM] Pre-pull Patch Posting swhiteho @ 2007-07-09 16:02 ` swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [DLM] fix a couple of races swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Benjamin Marzinski <bmarzins@redhat.com> Fix for bz #231910 When filemap_fdatawrite() is called on the inode mapping in data=ordered mode, it will add the glock to the log. In inode_go_sync(), if you do the gfs2_log_flush() before this, after the filemap_fdatawrite() call, the glock and its associated data buffers will be on the log again. This means you can demote a lock from exclusive, without having it flushed from the log. The attached patch simply moves the gfs2_log_flush up to after the filemap_fdatawrite() call. Originally, I tried moving the gfs2_log_flush to after gfs2_meta_sync(), but that caused me to trip the following assert. GFS2: fsid=cypher-36:test.0: fatal: assertion "!buffer_busy(bh)" failed GFS2: fsid=cypher-36:test.0: function = gfs2_ail_empty_gl, file = fs/gfs2/glops.c, line = 61 It appears that gfs2_log_flush() puts some of the glocks buffers in the busy state and the filemap_fdatawrite() call is necessary to flush them. This makes me worry slightly that a related problem could happen because of moving the gfs2_log_flush() after the initial filemap_fdatawrite(), but I assume that gfs2_ail_empty_gl() would catch that case as well. Signed-off-by: Benjamin E. Marzinski <bmarzins@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 7b82657..777ca46 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -156,9 +156,9 @@ static void inode_go_sync(struct gfs2_glock *gl) ip = NULL; if (test_bit(GLF_DIRTY, &gl->gl_flags)) { - gfs2_log_flush(gl->gl_sbd, gl); if (ip) filemap_fdatawrite(ip->i_inode.i_mapping); + gfs2_log_flush(gl->gl_sbd, gl); gfs2_meta_sync(gl); if (ip) { struct address_space *mapping = ip->i_inode.i_mapping; -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [DLM] fix a couple of races 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] flush the glock completely in inode_go_sync swhiteho @ 2007-07-09 16:02 ` swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] kernel changes to support new gfs2_grow command swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Satyam Sharma <ssatyam@cse.iitk.ac.in> Fix two races in fs/dlm/config.c: (1) Grab the configfs subsystem semaphore before calling config_group_find_obj() in get_space(). This solves a potential race between get_space() and concurrent mkdir(2) or rmdir(2). (2) Grab a reference on the found config_item _while_ holding the configfs subsystem semaphore in get_comm(), and not after it. This solves a potential race between get_comm() and concurrent rmdir(2). Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in> Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 822abdc..5a3d390 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -748,9 +748,16 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len) static struct space *get_space(char *name) { + struct config_item *i; + if (!space_list) return NULL; - return to_space(config_group_find_obj(space_list, name)); + + down(&space_list->cg_subsys->su_sem); + i = config_group_find_obj(space_list, name); + up(&space_list->cg_subsys->su_sem); + + return to_space(i); } static void put_space(struct space *sp) @@ -776,20 +783,20 @@ static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr) if (cm->nodeid != nodeid) continue; found = 1; + config_item_get(i); break; } else { if (!cm->addr_count || memcmp(cm->addr[0], addr, sizeof(*addr))) continue; found = 1; + config_item_get(i); break; } } up(&clusters_root.subsys.su_sem); - if (found) - config_item_get(i); - else + if (!found) cm = NULL; return cm; } -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [GFS2] kernel changes to support new gfs2_grow command 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [DLM] fix a couple of races swhiteho @ 2007-07-09 16:02 ` swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] Kernel changes to support new gfs2_grow command (part 2) swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Robert Peterson <rpeterso@redhat.com> This is another revision of my gfs2 kernel patch that allows gfs2_grow to function properly. Steve Whitehouse expressed some concerns about the previous patch and I restructured it based on his comments. The previous patch was doing the statfs_change at file close time, under its own transaction. The current patch does the statfs_change inside the gfs2_commit_write function, which keeps it under the umbrella of the inode transaction. I can't call ri_update to re-read the rindex file during the transaction because the transaction may have outstanding unwritten buffers attached to the rgrps that would be otherwise blown away. So instead, I created a new function, gfs2_ri_total, that will re-read the rindex file just to total the file system space for the sake of the statfs_change. The ri_update will happen later, when gfs2 realizes the version number has changed, as it happened before my patch. Since the statfs_change is happening at write_commit time and there may be multiple writes to the rindex file for one grow operation. So one consequence of this restructuring is that instead of getting one kernel message to indicate the change, you may see several. For example, before when you did a gfs2_grow, you'd get a single message like: GFS2: File system extended by 247876 blocks (968MB) Now you get something like: GFS2: File system extended by 207896 blocks (812MB) GFS2: File system extended by 39980 blocks (156MB) This version has also been successfully run against the hours-long "gfs2_fsck_hellfire" test that does several gfs2_grow and gfs2_fsck while interjecting file system damage. It does this repeatedly under a variety Resource Group conditions. Signed-off-By: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 30c1562..846c0ff 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions @@ -450,6 +450,30 @@ out_uninit: } /** + * adjust_fs_space - Adjusts the free space available due to gfs2_grow + * @inode: the rindex inode + */ +static void adjust_fs_space(struct inode *inode) +{ + struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; + struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; + struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; + u64 fs_total, new_free; + + /* Total up the file system space, according to the latest rindex. */ + fs_total = gfs2_ri_total(sdp); + + spin_lock(&sdp->sd_statfs_spin); + if (fs_total > (m_sc->sc_total + l_sc->sc_total)) + new_free = fs_total - (m_sc->sc_total + l_sc->sc_total); + else + new_free = 0; + spin_unlock(&sdp->sd_statfs_spin); + fs_warn(sdp, "File system extended by %llu blocks.\n", new_free); + gfs2_statfs_change(sdp, new_free, new_free, 0); +} + +/** * gfs2_commit_write - Commit write to a file * @file: The file to write to * @page: The page containing the data @@ -511,6 +535,9 @@ static int gfs2_commit_write(struct file *file, struct page *page, di->di_size = cpu_to_be64(inode->i_size); } + if (inode == sdp->sd_rindex) + adjust_fs_space(inode); + brelse(dibh); gfs2_trans_end(sdp); if (al->al_requested) { diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h index 35aaee4..56c30da 100644 --- a/fs/gfs2/ops_address.h +++ b/fs/gfs2/ops_address.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions @@ -18,5 +18,8 @@ extern const struct address_space_operations gfs2_file_aops; extern int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create); extern int gfs2_releasepage(struct page *page, gfp_t gfp_mask); +extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); +extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, + s64 dinodes); #endif /* __OPS_ADDRESS_DOT_H__ */ diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 1727f50..e857f40 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions @@ -431,6 +431,38 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) } /** + * gfs2_ri_total - Total up the file system space, according to the rindex. + * + */ +u64 gfs2_ri_total(struct gfs2_sbd *sdp) +{ + u64 total_data = 0; + struct inode *inode = sdp->sd_rindex; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_rindex_host ri; + char buf[sizeof(struct gfs2_rindex)]; + struct file_ra_state ra_state; + int error, rgrps; + + mutex_lock(&sdp->sd_rindex_mutex); + file_ra_state_init(&ra_state, inode->i_mapping); + for (rgrps = 0;; rgrps++) { + loff_t pos = rgrps * sizeof(struct gfs2_rindex); + + if (pos + sizeof(struct gfs2_rindex) >= ip->i_di.di_size) + break; + error = gfs2_internal_read(ip, &ra_state, buf, &pos, + sizeof(struct gfs2_rindex)); + if (error != sizeof(struct gfs2_rindex)) + break; + gfs2_rindex_in(&ri, buf); + total_data += ri.ri_data; + } + mutex_unlock(&sdp->sd_rindex_mutex); + return total_data; +} + +/** * gfs2_ri_update - Pull in a new resource index from the disk * @gl: The glock covering the rindex inode * @@ -447,7 +479,12 @@ static int gfs2_ri_update(struct gfs2_inode *ip) u64 junk = ip->i_di.di_size; int error; - if (do_div(junk, sizeof(struct gfs2_rindex))) { + /* If someone is holding the rindex file with a glock, they must + be updating it, in which case we may have partial entries. + In this case, we ignore the partials. */ + if (!gfs2_glock_is_held_excl(ip->i_gl) && + !gfs2_glock_is_held_shrd(ip->i_gl) && + do_div(junk, sizeof(struct gfs2_rindex))) { gfs2_consist_inode(ip); return -EIO; } @@ -457,6 +494,9 @@ static int gfs2_ri_update(struct gfs2_inode *ip) file_ra_state_init(&ra_state, inode->i_mapping); for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex); + + if (pos + sizeof(struct gfs2_rindex) >= ip->i_di.di_size) + break; error = gfs2_internal_read(ip, &ra_state, buf, &pos, sizeof(struct gfs2_rindex)); if (!error) @@ -978,18 +1018,25 @@ int gfs2_inplace_reserve_i(struct gfs2_inode *ip, char *file, unsigned int line) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; - int error; + int error = 0; if (gfs2_assert_warn(sdp, al->al_requested)) return -EINVAL; - error = gfs2_rindex_hold(sdp, &al->al_ri_gh); + /* We need to hold the rindex unless the inode we're using is + the rindex itself, in which case it's already held. */ + if (ip != GFS2_I(sdp->sd_rindex)) + error = gfs2_rindex_hold(sdp, &al->al_ri_gh); + else if (!sdp->sd_rgrps) /* We may not have the rindex read in, so: */ + error = gfs2_ri_update(ip); + if (error) return error; error = get_local_rgrp(ip); if (error) { - gfs2_glock_dq_uninit(&al->al_ri_gh); + if (ip != GFS2_I(sdp->sd_rindex)) + gfs2_glock_dq_uninit(&al->al_ri_gh); return error; } @@ -1019,7 +1066,8 @@ void gfs2_inplace_release(struct gfs2_inode *ip) al->al_rgd = NULL; gfs2_glock_dq_uninit(&al->al_rgd_gh); - gfs2_glock_dq_uninit(&al->al_ri_gh); + if (ip != GFS2_I(sdp->sd_rindex)) + gfs2_glock_dq_uninit(&al->al_ri_gh); } /** -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [GFS2] Kernel changes to support new gfs2_grow command (part 2) 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] kernel changes to support new gfs2_grow command swhiteho @ 2007-07-09 16:02 ` swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] use zero_user_page swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Robert Peterson <rpeterso@redhat.com> To avoid code redundancy, I separated out the operational "guts" into a new function called read_rindex_entry. Then I made two functions: the closer-to-original gfs2_ri_update (without the special condition checks) and gfs2_ri_update_special that's designed with that condition in mind. (I don't like the name, but if you have a suggestion, I'm all ears). Oh, and there's an added benefit: we don't need all the ugly gotos anymore. ;) This patch has been tested with gfs2_fsck_hellfire (which runs for three and a half hours, btw). Signed-off-By: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 846c0ff..e0b4e8c 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -469,7 +469,8 @@ static void adjust_fs_space(struct inode *inode) else new_free = 0; spin_unlock(&sdp->sd_statfs_spin); - fs_warn(sdp, "File system extended by %llu blocks.\n", new_free); + fs_warn(sdp, "File system extended by %llu blocks.\n", + (unsigned long long)new_free); gfs2_statfs_change(sdp, new_free, new_free, 0); } diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index e857f40..48a6461 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -463,9 +463,62 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) } /** - * gfs2_ri_update - Pull in a new resource index from the disk + * read_rindex_entry - Pull in a new resource index entry from the disk * @gl: The glock covering the rindex inode * + * Returns: 0 on success, error code otherwise + */ + +static int read_rindex_entry(struct gfs2_inode *ip, + struct file_ra_state *ra_state) +{ + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex); + char buf[sizeof(struct gfs2_rindex)]; + int error; + struct gfs2_rgrpd *rgd; + + error = gfs2_internal_read(ip, ra_state, buf, &pos, + sizeof(struct gfs2_rindex)); + if (!error) + return 0; + if (error != sizeof(struct gfs2_rindex)) { + if (error > 0) + error = -EIO; + return error; + } + + rgd = kzalloc(sizeof(struct gfs2_rgrpd), GFP_NOFS); + error = -ENOMEM; + if (!rgd) + return error; + + mutex_init(&rgd->rd_mutex); + lops_init_le(&rgd->rd_le, &gfs2_rg_lops); + rgd->rd_sbd = sdp; + + list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); + list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); + + gfs2_rindex_in(&rgd->rd_ri, buf); + error = compute_bitstructs(rgd); + if (error) + return error; + + error = gfs2_glock_get(sdp, rgd->rd_ri.ri_addr, + &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); + if (error) + return error; + + rgd->rd_gl->gl_object = rgd; + rgd->rd_rg_vn = rgd->rd_gl->gl_vn - 1; + return error; +} + +/** + * gfs2_ri_update - Pull in a new resource index from the disk + * @ip: pointer to the rindex inode + * * Returns: 0 on successful update, error code otherwise */ @@ -473,18 +526,11 @@ static int gfs2_ri_update(struct gfs2_inode *ip) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *inode = &ip->i_inode; - struct gfs2_rgrpd *rgd; - char buf[sizeof(struct gfs2_rindex)]; struct file_ra_state ra_state; u64 junk = ip->i_di.di_size; int error; - /* If someone is holding the rindex file with a glock, they must - be updating it, in which case we may have partial entries. - In this case, we ignore the partials. */ - if (!gfs2_glock_is_held_excl(ip->i_gl) && - !gfs2_glock_is_held_shrd(ip->i_gl) && - do_div(junk, sizeof(struct gfs2_rindex))) { + if (do_div(junk, sizeof(struct gfs2_rindex))) { gfs2_consist_inode(ip); return -EIO; } @@ -493,52 +539,49 @@ static int gfs2_ri_update(struct gfs2_inode *ip) file_ra_state_init(&ra_state, inode->i_mapping); for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { - loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex); - - if (pos + sizeof(struct gfs2_rindex) >= ip->i_di.di_size) - break; - error = gfs2_internal_read(ip, &ra_state, buf, &pos, - sizeof(struct gfs2_rindex)); - if (!error) - break; - if (error != sizeof(struct gfs2_rindex)) { - if (error > 0) - error = -EIO; - goto fail; + error = read_rindex_entry(ip, &ra_state); + if (error) { + clear_rgrpdi(sdp); + return error; } + } - rgd = kzalloc(sizeof(struct gfs2_rgrpd), GFP_NOFS); - error = -ENOMEM; - if (!rgd) - goto fail; - - mutex_init(&rgd->rd_mutex); - lops_init_le(&rgd->rd_le, &gfs2_rg_lops); - rgd->rd_sbd = sdp; - - list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); - list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); - - gfs2_rindex_in(&rgd->rd_ri, buf); - error = compute_bitstructs(rgd); - if (error) - goto fail; + sdp->sd_rindex_vn = ip->i_gl->gl_vn; + return 0; +} - error = gfs2_glock_get(sdp, rgd->rd_ri.ri_addr, - &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); - if (error) - goto fail; +/** + * gfs2_ri_update_special - Pull in a new resource index from the disk + * + * This is a special version that's safe to call from gfs2_inplace_reserve_i. + * In this case we know that we don't have any resource groups in memory yet. + * + * @ip: pointer to the rindex inode + * + * Returns: 0 on successful update, error code otherwise + */ +static int gfs2_ri_update_special(struct gfs2_inode *ip) +{ + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct inode *inode = &ip->i_inode; + struct file_ra_state ra_state; + int error; - rgd->rd_gl->gl_object = rgd; - rgd->rd_rg_vn = rgd->rd_gl->gl_vn - 1; + file_ra_state_init(&ra_state, inode->i_mapping); + for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { + /* Ignore partials */ + if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) > + ip->i_di.di_size) + break; + error = read_rindex_entry(ip, &ra_state); + if (error) { + clear_rgrpdi(sdp); + return error; + } } sdp->sd_rindex_vn = ip->i_gl->gl_vn; return 0; - -fail: - clear_rgrpdi(sdp); - return error; } /** @@ -1028,7 +1071,7 @@ int gfs2_inplace_reserve_i(struct gfs2_inode *ip, char *file, unsigned int line) if (ip != GFS2_I(sdp->sd_rindex)) error = gfs2_rindex_hold(sdp, &al->al_ri_gh); else if (!sdp->sd_rgrps) /* We may not have the rindex read in, so: */ - error = gfs2_ri_update(ip); + error = gfs2_ri_update_special(ip); if (error) return error; -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [GFS2] use zero_user_page 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] Kernel changes to support new gfs2_grow command (part 2) swhiteho @ 2007-07-09 16:02 ` swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] Addendum patch 2 for gfs2_grow swhiteho 0 siblings, 1 reply; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Nate Diller <nate.diller@gmail.com> Use zero_user_page() instead of open-coding it. Signed-off-by: Nate Diller <nate.diller@gmail.com> Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index c53a5d2..1c40c4b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -885,7 +885,6 @@ static int gfs2_block_truncate_page(struct address_space *mapping) unsigned blocksize, iblock, length, pos; struct buffer_head *bh; struct page *page; - void *kaddr; int err; page = grab_cache_page(mapping, index); @@ -933,10 +932,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping) if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) gfs2_trans_add_bh(ip->i_gl, bh, 0); - kaddr = kmap_atomic(page, KM_USER0); - memset(kaddr + offset, 0, length); - flush_dcache_page(page); - kunmap_atomic(kaddr, KM_USER0); + zero_user_page(page, offset, length, KM_USER0); unlock: unlock_page(page); -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH] [GFS2] Addendum patch 2 for gfs2_grow 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] use zero_user_page swhiteho @ 2007-07-09 16:02 ` swhiteho 0 siblings, 0 replies; 3+ messages in thread From: swhiteho @ 2007-07-09 16:02 UTC (permalink / raw) To: cluster-devel.redhat.com From: Robert Peterson <rpeterso@redhat.com> This addendum patch 2 corrects three things: 1. It fixes a stupid mistake in the previous addendum that broke gfs2. Ref: https://www.redhat.com/archives/cluster-devel/2007-May/msg00162.html 2. It fixes a problem that Dave Teigland pointed out regarding the external declarations in ops_address.h being in the wrong place. 3. It recasts a couple more %llu printks to (unsigned long long) as requested by Steve Whitehouse. I would have loved to put this all in one revised patch, but there was a rush to get some patches for RHEL5. Therefore, the previous patches were applied to the git tree "as is" and therefore, I'm posting another addendum. Sorry. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1815429..c66c718 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1823,7 +1823,8 @@ static int dump_inode(struct glock_iter *gi, struct gfs2_inode *ip) print_dbg(gi, " Inode:\n"); print_dbg(gi, " num = %llu/%llu\n", - ip->i_num.no_formal_ino, ip->i_num.no_addr); + (unsigned long long)ip->i_num.no_formal_ino, + (unsigned long long)ip->i_num.no_addr); print_dbg(gi, " type = %u\n", IF2DT(ip->i_inode.i_mode)); print_dbg(gi, " i_flags ="); for (x = 0; x < 32; x++) @@ -1909,8 +1910,8 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl) } if (test_bit(GLF_DEMOTE, &gl->gl_flags)) { print_dbg(gi, " Demotion req to state %u (%llu uS ago)\n", - gl->gl_demote_state, - (u64)(jiffies - gl->gl_demote_time)*(1000000/HZ)); + gl->gl_demote_state, (unsigned long long) + (jiffies - gl->gl_demote_time)*(1000000/HZ)); } if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) { if (!test_bit(GLF_LOCK, &gl->gl_flags) && diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index e0b4e8c..4913ef5 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -32,6 +32,7 @@ #include "trans.h" #include "rgrp.h" #include "ops_file.h" +#include "super.h" #include "util.h" #include "glops.h" diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h index 56c30da..fa1b5b3 100644 --- a/fs/gfs2/ops_address.h +++ b/fs/gfs2/ops_address.h @@ -18,8 +18,5 @@ extern const struct address_space_operations gfs2_file_aops; extern int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create); extern int gfs2_releasepage(struct page *page, gfp_t gfp_mask); -extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); -extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, - s64 dinodes); #endif /* __OPS_ADDRESS_DOT_H__ */ diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 48a6461..a62c0f2 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -527,10 +527,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *inode = &ip->i_inode; struct file_ra_state ra_state; - u64 junk = ip->i_di.di_size; + u64 rgrp_count = ip->i_di.di_size; int error; - if (do_div(junk, sizeof(struct gfs2_rindex))) { + if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { gfs2_consist_inode(ip); return -EIO; } @@ -538,7 +538,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) clear_rgrpdi(sdp); file_ra_state_init(&ra_state, inode->i_mapping); - for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { + for (sdp->sd_rgrps = 0; sdp->sd_rgrps < rgrp_count; sdp->sd_rgrps++) { error = read_rindex_entry(ip, &ra_state); if (error) { clear_rgrpdi(sdp); diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index b01e0cf..b4c6adf 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -65,5 +65,6 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state, int flags); void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); +u64 gfs2_ri_total(struct gfs2_sbd *sdp); #endif /* __RGRP_DOT_H__ */ -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-09 16:02 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-05-14 17:42 [Cluster-devel] [PATCH] GFS2: Addendum patch 2 for gfs2_grow Robert Peterson 2007-05-15 8:48 ` Steven Whitehouse -- strict thread matches above, loose matches on Subject: below -- 2007-07-09 16:02 [Cluster-devel] [GFS2/DLM] Pre-pull Patch Posting swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] flush the glock completely in inode_go_sync swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [DLM] fix a couple of races swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] kernel changes to support new gfs2_grow command swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] Kernel changes to support new gfs2_grow command (part 2) swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] use zero_user_page swhiteho 2007-07-09 16:02 ` [Cluster-devel] [PATCH] [GFS2] Addendum patch 2 for gfs2_grow swhiteho
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).