From 7276b3b0c77101f8b3f4e45e89a29cf9045e831a Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 21 Sep 2006 17:05:23 -0400 Subject: [GFS2] Tidy up meta_io code Fix a bug in the directory reading code, where we might have dereferenced a NULL pointer in case of OOM. Updated the directory code to use the new & improved version of gfs2_meta_ra() which now returns the first block that was being read. Previously it was releasing it requiring following code to grab the block again at each point it was called. Also turned off readahead on directory lookups since we are reading a hash table, and therefore reading the entries in order is very unlikely. Readahead is still used for all other calls to the directory reading function (e.g. when growing the hash table). Removed the DIO_START constant. Everywhere this was used, it was used to unconditionally start i/o aside from a couple of places, so I've removed it and made the couple of exceptions to this rule into separate functions. Also hunted through the other DIO flags and removed them as arguments from functions which were always called with the same combination of arguments. Updated gfs2_meta_indirect_buffer to be a bit more efficient and hopefully also be a bit easier to read. Signed-off-by: Steven Whitehouse --- fs/gfs2/glops.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'fs/gfs2/glops.c') diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 9c046dbf472..ef1492e2d44 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -77,32 +77,24 @@ static void gfs2_page_inval(struct gfs2_glock *gl) } /** - * gfs2_page_sync - Sync the data pages (not metadata) associated with a glock + * gfs2_page_wait - Wait for writeback of data * @gl: the glock - * @flags: DIO_START | DIO_WAIT * * Syncs data (not metadata) for a regular file. * No-op for all other types. */ -static void gfs2_page_sync(struct gfs2_glock *gl, int flags) +static void gfs2_page_wait(struct gfs2_glock *gl) { - struct gfs2_inode *ip; - struct inode *inode; - struct address_space *mapping; - int error = 0; + struct gfs2_inode *ip = gl->gl_object; + struct inode *inode = &ip->i_inode; + struct address_space *mapping = inode->i_mapping; + int error; - ip = gl->gl_object; - inode = &ip->i_inode; - if (!ip || !S_ISREG(ip->i_di.di_mode)) + if (!S_ISREG(ip->i_di.di_mode)) return; - mapping = inode->i_mapping; - - if (flags & DIO_START) - filemap_fdatawrite(mapping); - if (!error && (flags & DIO_WAIT)) - error = filemap_fdatawait(mapping); + error = filemap_fdatawait(mapping); /* Put back any errors cleared by filemap_fdatawait() so they can be caught by someone who can pass them @@ -115,6 +107,18 @@ static void gfs2_page_sync(struct gfs2_glock *gl, int flags) } +static void gfs2_page_writeback(struct gfs2_glock *gl) +{ + struct gfs2_inode *ip = gl->gl_object; + struct inode *inode = &ip->i_inode; + struct address_space *mapping = inode->i_mapping; + + if (!S_ISREG(ip->i_di.di_mode)) + return; + + filemap_fdatawrite(mapping); +} + /** * meta_go_sync - sync out the metadata for this glock * @gl: the glock @@ -132,7 +136,7 @@ static void meta_go_sync(struct gfs2_glock *gl, int flags) if (test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) { gfs2_log_flush(gl->gl_sbd, gl); - gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT); + gfs2_meta_sync(gl); if (flags & DIO_RELEASE) gfs2_ail_empty_gl(gl); } @@ -185,8 +189,7 @@ static void inode_go_xmote_bh(struct gfs2_glock *gl) if (gl->gl_state != LM_ST_UNLOCKED && (!gh || !(gh->gh_flags & GL_SKIP))) { - error = gfs2_meta_read(gl, gl->gl_name.ln_number, DIO_START, - &bh); + error = gfs2_meta_read(gl, gl->gl_name.ln_number, 0, &bh); if (!error) brelse(bh); } @@ -221,16 +224,18 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags) if (test_bit(GLF_DIRTY, &gl->gl_flags)) { if (meta && data) { - gfs2_page_sync(gl, flags | DIO_START); + gfs2_page_writeback(gl); gfs2_log_flush(gl->gl_sbd, gl); - gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT); - gfs2_page_sync(gl, flags | DIO_WAIT); + gfs2_meta_sync(gl); + gfs2_page_wait(gl); clear_bit(GLF_DIRTY, &gl->gl_flags); } else if (meta) { gfs2_log_flush(gl->gl_sbd, gl); - gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT); - } else if (data) - gfs2_page_sync(gl, flags | DIO_START | DIO_WAIT); + gfs2_meta_sync(gl); + } else if (data) { + gfs2_page_writeback(gl); + gfs2_page_wait(gl); + } if (flags & DIO_RELEASE) gfs2_ail_empty_gl(gl); } -- cgit v1.2.3