aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2013-12-06 05:16:14 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2014-01-03 05:00:31 -0500
commit7005c3e4ae42858dbb695b2d03d340af799b1f1b (patch)
tree25e3ce7a1dccb1784ca1b09f03a0382265b82370
parent7de41d36ff5885141a16c74a044936cf878c770f (diff)
GFS2: Use range based functions for rgrp sync/invalidation
Each rgrp header is represented as a single extent on disk, so we can calculate the position within the address space, since we are using address spaces mapped 1:1 to the disk. This means that it is possible to use the range based versions of filemap_fdatawrite/wait and for invalidating the page cache. Our eventual intent is to then be able to merge the address spaces used for rgrps into a single address space, rather than to have one for each glock, saving memory and reducing complexity. Since during umount, the rgrp structures are disposed of before the glocks, we need to store the extent information in the glock so that is is available for a final invalidation. This patch uses a field which is otherwise unused in rgrp glocks to do that, so that we do not have to expand the size of a glock. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/glops.c6
-rw-r--r--fs/gfs2/incore.h10
-rw-r--r--fs/gfs2/rgrp.c3
3 files changed, 15 insertions, 4 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index f88dcd925010..1b192c8d404d 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -142,8 +142,8 @@ static void rgrp_go_sync(struct gfs2_glock *gl)
142 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE); 142 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE);
143 143
144 gfs2_log_flush(gl->gl_sbd, gl); 144 gfs2_log_flush(gl->gl_sbd, gl);
145 filemap_fdatawrite(metamapping); 145 filemap_fdatawrite_range(metamapping, gl->gl_vm.start, gl->gl_vm.end);
146 error = filemap_fdatawait(metamapping); 146 error = filemap_fdatawait_range(metamapping, gl->gl_vm.start, gl->gl_vm.end);
147 mapping_set_error(metamapping, error); 147 mapping_set_error(metamapping, error);
148 gfs2_ail_empty_gl(gl); 148 gfs2_ail_empty_gl(gl);
149 149
@@ -170,7 +170,7 @@ static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
170 170
171 WARN_ON_ONCE(!(flags & DIO_METADATA)); 171 WARN_ON_ONCE(!(flags & DIO_METADATA));
172 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count)); 172 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
173 truncate_inode_pages(mapping, 0); 173 truncate_inode_pages_range(mapping, gl->gl_vm.start, gl->gl_vm.end);
174 174
175 if (gl->gl_object) { 175 if (gl->gl_object) {
176 struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object; 176 struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object;
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 01328162c952..e6544ee0c137 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -351,7 +351,15 @@ struct gfs2_glock {
351 atomic_t gl_ail_count; 351 atomic_t gl_ail_count;
352 atomic_t gl_revokes; 352 atomic_t gl_revokes;
353 struct delayed_work gl_work; 353 struct delayed_work gl_work;
354 struct work_struct gl_delete; 354 union {
355 /* For inode and iopen glocks only */
356 struct work_struct gl_delete;
357 /* For rgrp glocks only */
358 struct {
359 loff_t start;
360 loff_t end;
361 } gl_vm;
362 };
355 struct rcu_head gl_rcu; 363 struct rcu_head gl_rcu;
356}; 364};
357 365
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 2584710f6459..183cf0f0052d 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -886,6 +886,7 @@ static int rgd_insert(struct gfs2_rgrpd *rgd)
886static int read_rindex_entry(struct gfs2_inode *ip) 886static int read_rindex_entry(struct gfs2_inode *ip)
887{ 887{
888 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 888 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
889 const unsigned bsize = sdp->sd_sb.sb_bsize;
889 loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex); 890 loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex);
890 struct gfs2_rindex buf; 891 struct gfs2_rindex buf;
891 int error; 892 int error;
@@ -923,6 +924,8 @@ static int read_rindex_entry(struct gfs2_inode *ip)
923 goto fail; 924 goto fail;
924 925
925 rgd->rd_gl->gl_object = rgd; 926 rgd->rd_gl->gl_object = rgd;
927 rgd->rd_gl->gl_vm.start = rgd->rd_addr * bsize;
928 rgd->rd_gl->gl_vm.end = rgd->rd_gl->gl_vm.start + (rgd->rd_length * bsize) - 1;
926 rgd->rd_rgl = (struct gfs2_rgrp_lvb *)rgd->rd_gl->gl_lksb.sb_lvbptr; 929 rgd->rd_rgl = (struct gfs2_rgrp_lvb *)rgd->rd_gl->gl_lksb.sb_lvbptr;
927 rgd->rd_flags &= ~GFS2_RDF_UPTODATE; 930 rgd->rd_flags &= ~GFS2_RDF_UPTODATE;
928 if (rgd->rd_data > sdp->sd_max_rg_data) 931 if (rgd->rd_data > sdp->sd_max_rg_data)