GFS2: Pre-pull patch posting
Hi,
I know the merge window isn't open yet, but at this stage I'm going to hold off on any larger patches until the following merge window so this patch set isn't likely to change much, hence kicking it out a bit early for review.
There are a few interesting points to note in this patch set:
o GFS2 is updated to use the new truncate sequence
o Support for fallocate is added
o Clean up of some unused/obsolete mount options
I'm currently working on a patch to allow the glock hash table to use RCU. That is currently a work-in-progress and that will hopefully be ready for the succeeding merge window.
Steve.
PATCH 1/22 GFS2: New truncate sequence
This updates GFS2's truncate code to use the new truncate sequence correctly. This is a stepping stone to being able to remove ip->i_disksize in favour of using i_size everywhere now that the two sizes are always identical.
fs/gfs2/aops.c +4 -6
@@ -696,13 +696,11 @@ out:page_cache_release (page); -/* -* XXX(truncate): the call below should probably be replaced with -* a call to the gfs2-specific truncate blocks helper to actually -* release disk blocks.. -*/ +gfs2_trans_end (sdp);if (pos + len > ip->i_inode.i_size) -truncate_setsize (&ip->i_inode, ip->i_inode.i_size); +gfs2_trim_blocks (&ip->i_inode); + goto out_trans_fail; + out_endtrans:gfs2_trans_end (sdp); out_trans_fail:
fs/gfs2/bmap.c +119 -128
343 lines not on this page · raw message
fs/gfs2/bmap.h +11 -9
@@ -44,14 +44,16 @@ static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip, } } -int gfs2_unstuff_dinode (struct gfs2_inode *ip,struct page *page); -int gfs2_block_map (struct inode *inode,sector_t lblock,struct buffer_head *bh,int create); -int gfs2_extent_map (struct inode *inode,u64 lblock,int *new,u64 *dblock,unsigned *extlen); - -int gfs2_truncatei (struct gfs2_inode *ip,u64 size); -int gfs2_truncatei_resume (struct gfs2_inode *ip); -int gfs2_file_dealloc (struct gfs2_inode *ip); -int gfs2_write_alloc_required (struct gfs2_inode *ip,u64 offset, -unsigned int len); +extern int gfs2_unstuff_dinode (struct gfs2_inode *ip,struct page *page); +extern int gfs2_block_map (struct inode *inode,sector_t lblock, +struct buffer_head *bh,int create); +extern int gfs2_extent_map (struct inode *inode,u64 lblock,int *new, +u64 *dblock,unsigned *extlen); +extern int gfs2_setattr_size (struct inode *inode,u64 size); +extern void gfs2_trim_blocks (struct inode *inode); +extern int gfs2_truncatei_resume (struct gfs2_inode *ip); +extern int gfs2_file_dealloc (struct gfs2_inode *ip); +extern int gfs2_write_alloc_required (struct gfs2_inode *ip,u64 offset, +unsigned int len);#endif /* __BMAP_DOT_H__ */
fs/gfs2/ops_inode.c +1 -25
@@ -1071,30 +1071,6 @@ int gfs2_permission(struct inode *inode, int mask)return error; } -/* -* XXX(truncate): the truncate_setsize calls should be moved to the end. -*/ -static int setattr_size (struct inode *inode,struct iattr *attr) -{ -struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_sbd *sdp =GFS2_SB (inode); -int error; - -if (attr->ia_size != ip->i_disksize) { - error =gfs2_trans_begin (sdp,0 , sdp->sd_jdesc->jd_blocks); -if (error) -return error; -truncate_setsize (inode, attr->ia_size); -gfs2_trans_end (sdp); - } - - error =gfs2_truncatei (ip, attr->ia_size); -if (error && (inode->i_size != ip->i_disksize)) -i_size_write (inode, ip->i_disksize); - -return error; -} -static int setattr_chown (struct inode *inode,struct iattr *attr) {struct gfs2_inode *ip =GFS2_I (inode);
@@ -1195,7 +1171,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) goto out;if (attr->ia_valid &ATTR_SIZE ) - error =setattr_size (inode, attr); + error =gfs2_setattr_size (inode, attr->ia_size);else if (attr->ia_valid & (ATTR_UID |ATTR_GID )) error =setattr_chown (inode, attr);else if ((attr->ia_valid &ATTR_MODE ) &&IS_POSIXACL (inode))
Signature · 1 line
1.7.1.1
PATCH 2/22 GFS2: Remove i_disksize
In reply to Steven WhitehouseWith the update of the truncate code, ip->i_disksize and inode->i_size are merely copies of each other. This means we can remove ip->i_disksize and use inode->i_size exclusively reducing the size of a GFS2 inode by 8 bytes.
fs/gfs2/aops.c +1 -5
@@ -800,10 +800,8 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,page_cache_release (page);if (copied) { -if (inode->i_size < to) { +if (inode->i_size < to)i_size_write (inode, to); - ip->i_disksize = inode->i_size; - }gfs2_dinode_out (ip, di);mark_inode_dirty (inode); }
@@ -874,8 +872,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, ret =generic_write_end (file, mapping, pos, len, copied, page, fsdata);if (ret >0 ) { -if (inode->i_size > ip->i_disksize) - ip->i_disksize = inode->i_size;gfs2_dinode_out (ip, dibh->b_data);mark_inode_dirty (inode); }
fs/gfs2/bmap.c +5 -7
@@ -131,7 +131,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)if (error) goto out; -if (ip->i_disksize) { +if (i_size_read (&ip->i_inode)) {/* Get a free block, fill it with the stuffed data, and write it out to disk */
@@ -160,7 +160,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) di = (struct gfs2_dinode *)dibh->b_data;gfs2_buffer_clear_tail (dibh,sizeof (struct gfs2_dinode )); -if (ip->i_disksize) { +if (i_size_read (&ip->i_inode)) { *(__be64 *)(di +1 ) =cpu_to_be64 (block);gfs2_add_inode_blocks (&ip->i_inode,1 ); di->di_blocks =cpu_to_be64 (gfs2_get_inode_blocks (&ip->i_inode));
@@ -985,7 +985,6 @@ static int trunc_start(struct inode *inode, u64 oldsize, u64 newsize) }i_size_write (inode, newsize); - ip->i_disksize = newsize; ip->i_inode.i_mtime = ip->i_inode.i_ctime =CURRENT_TIME ;gfs2_dinode_out (ip, dibh->b_data);
@@ -1051,7 +1050,7 @@ static int trunc_end(struct gfs2_inode *ip)if (error) goto out; -if (!ip->i_disksize) { +if (!i_size_read (&ip->i_inode)) { ip->i_height =0 ; ip->i_goal = ip->i_no_addr;gfs2_buffer_clear_tail (dibh,sizeof (struct gfs2_dinode ));
@@ -1167,7 +1166,6 @@ static int do_grow(struct inode *inode, u64 size) goto do_end_trans;i_size_write (inode, size); - ip->i_disksize = size; ip->i_inode.i_mtime = ip->i_inode.i_ctime =CURRENT_TIME ;gfs2_trans_add_bh (ip->i_gl, dibh,1 );gfs2_dinode_out (ip, dibh->b_data);
@@ -1219,7 +1217,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)int gfs2_truncatei_resume (struct gfs2_inode *ip) {int error; - error =trunc_dealloc (ip, ip->i_disksize); + error =trunc_dealloc (ip,i_size_read (&ip->i_inode));if (!error) error =trunc_end (ip);return error;
@@ -1260,7 +1258,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, shift = sdp->sd_sb.sb_bsize_shift;BUG_ON (gfs2_is_dir (ip)); - end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize -1 ) >> shift; + end_of_file = (i_size_read (&ip->i_inode) + sdp->sd_sb.sb_bsize -1 ) >> shift; lblock = offset >> shift; lblock_stop = (offset + len + sdp->sd_sb.sb_bsize -1 ) >> shift;if (lblock_stop > end_of_file)
fs/gfs2/dir.c +15 -13
@@ -127,8 +127,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,gfs2_trans_add_bh (ip->i_gl, dibh,1 );memcpy (dibh->b_data + offset +sizeof (struct gfs2_dinode ), buf, size); -if (ip->i_disksize < offset + size) - ip->i_disksize = offset + size; +if (ip->i_inode.i_size < offset + size) +i_size_write (&ip->i_inode, offset + size); ip->i_inode.i_mtime = ip->i_inode.i_ctime =CURRENT_TIME ;gfs2_dinode_out (ip, dibh->b_data);
@@ -225,8 +225,8 @@ out:if (error)return error; -if (ip->i_disksize < offset + copied) - ip->i_disksize = offset + copied; +if (ip->i_inode.i_size < offset + copied) +i_size_write (&ip->i_inode, offset + copied); ip->i_inode.i_mtime = ip->i_inode.i_ctime =CURRENT_TIME ;gfs2_trans_add_bh (ip->i_gl, dibh,1 );
@@ -275,12 +275,13 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,unsigned int o;int copied =0 ;int error =0 ; +u64 disksize =i_size_read (&ip->i_inode); -if (offset >= ip->i_disksize) +if (offset >= disksize)return 0 ; -if (offset + size > ip->i_disksize) - size = ip->i_disksize - offset; +if (offset + size > disksize) + size = disksize - offset;if (!size)return 0 ;
@@ -727,7 +728,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,unsigned hsize =1 << ip->i_depth;unsigned index;u64 ln; -if (hsize *sizeof (u64) != ip->i_disksize) { +if (hsize *sizeof (u64) !=i_size_read (inode)) {gfs2_consist_inode (ip);return ERR_PTR (-EIO ); }
@@ -879,7 +880,7 @@ static int dir_make_exhash(struct inode *inode)for (x = sdp->sd_hash_ptrs; x--; lp++) *lp =cpu_to_be64 (bn); - dip->i_disksize = sdp->sd_sb.sb_bsize /2 ; +i_size_write (inode, sdp->sd_sb.sb_bsize /2 );gfs2_add_inode_blocks (&dip->i_inode,1 ); dip->i_diskflags |=GFS2_DIF_EXHASH ;
@@ -1057,11 +1058,12 @@ static int dir_double_exhash(struct gfs2_inode *dip)u64 *buf;u64 *from, *to;u64 block; +u64 disksize =i_size_read (&dip->i_inode);int x;int error =0 ; hsize =1 << dip->i_depth; -if (hsize *sizeof (u64) != dip->i_disksize) { +if (hsize *sizeof (u64) != disksize) {gfs2_consist_inode (dip);return -EIO ; }
@@ -1072,7 +1074,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)if (!buf)return -ENOMEM ; -for (block = dip->i_disksize >> sdp->sd_hash_bsize_shift; block--;) { +for (block = disksize >> sdp->sd_hash_bsize_shift; block--;) { error =gfs2_dir_read_data (dip, (char *)buf, block * sdp->sd_hash_bsize, sdp->sd_hash_bsize,1 );
@@ -1370,7 +1372,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,unsigned depth =0 ; hsize =1 << dip->i_depth; -if (hsize *sizeof (u64) != dip->i_disksize) { +if (hsize *sizeof (u64) !=i_size_read (inode)) {gfs2_consist_inode (dip);return -EIO ; }
@@ -1784,7 +1786,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)int error =0 ; hsize =1 << dip->i_depth; -if (hsize *sizeof (u64) != dip->i_disksize) { +if (hsize *sizeof (u64) !=i_size_read (&dip->i_inode)) {gfs2_consist_inode (dip);return -EIO ; }
fs/gfs2/file.c +1 -1
@@ -491,7 +491,7 @@ static int gfs2_open(struct inode *inode, struct file *file) goto fail;if (!(file->f_flags &O_LARGEFILE ) && - ip->i_disksize >MAX_NON_LFS ) { +i_size_read (inode) >MAX_NON_LFS ) { error = -EOVERFLOW ; goto fail_gunlock; }
fs/gfs2/glops.c +2 -3
@@ -262,13 +262,12 @@ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)const struct gfs2_inode *ip = gl->gl_object;if (ip ==NULL )return 0 ; -gfs2_print_dbg (seq," I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu/%llu\n" , +gfs2_print_dbg (seq," I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n" , (unsigned long long )ip->i_no_formal_ino, (unsigned long long )ip->i_no_addr,IF2DT (ip->i_inode.i_mode), ip->i_flags, (unsigned int )ip->i_diskflags, - (unsigned long long )ip->i_inode.i_size, - (unsigned long long )ip->i_disksize); + (unsigned long long )i_size_read (&ip->i_inode));return 0 ; }
fs/gfs2/incore.h +0 -1
@@ -267,7 +267,6 @@ struct gfs2_inode {u64 i_no_formal_ino;u64 i_generation;u64 i_eattr; -loff_t i_disksize;unsigned long i_flags;/* GIF_... */ struct gfs2_glock *i_gl;/* Move into i_gh? */ struct gfs2_holder i_iopen_gh;
fs/gfs2/inode.c +4 -5
@@ -359,8 +359,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)* to do that. */ ip->i_inode.i_nlink =be32_to_cpu (str->di_nlink); - ip->i_disksize =be64_to_cpu (str->di_size); -i_size_write (&ip->i_inode, ip->i_disksize); +i_size_write (&ip->i_inode,be64_to_cpu (str->di_size));gfs2_set_inode_blocks (&ip->i_inode,be64_to_cpu (str->di_blocks)); atime.tv_sec =be64_to_cpu (str->di_atime); atime.tv_nsec =be32_to_cpu (str->di_atime_nsec);
@@ -1055,7 +1054,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) str->di_uid =cpu_to_be32 (ip->i_inode.i_uid); str->di_gid =cpu_to_be32 (ip->i_inode.i_gid); str->di_nlink =cpu_to_be32 (ip->i_inode.i_nlink); - str->di_size =cpu_to_be64 (ip->i_disksize); + str->di_size =cpu_to_be64 (i_size_read (&ip->i_inode)); str->di_blocks =cpu_to_be64 (gfs2_get_inode_blocks (&ip->i_inode)); str->di_atime =cpu_to_be64 (ip->i_inode.i_atime.tv_sec); str->di_mtime =cpu_to_be64 (ip->i_inode.i_mtime.tv_sec);
@@ -1085,8 +1084,8 @@ void gfs2_dinode_print(const struct gfs2_inode *ip) (unsigned long long)ip->i_no_formal_ino);printk (KERN_INFO " no_addr = %llu\n" , (unsigned long long )ip->i_no_addr); -printk (KERN_INFO " i_disksize = %llu\n" , - (unsigned long long )ip->i_disksize); +printk (KERN_INFO " i_size = %llu\n" , + (unsigned long long )i_size_read (&ip->i_inode));printk (KERN_INFO " blocks = %llu\n" , (unsigned long long )gfs2_get_inode_blocks (&ip->i_inode)); printk(KERN_INFO " i_goal = %llu\n",
fs/gfs2/inode.h +13 -0
@@ -80,6 +80,19 @@ static inline void gfs2_inum_out(const struct gfs2_inode *ip, dent->de_inum.no_addr =cpu_to_be64 (ip->i_no_addr); } +static inline int gfs2_check_internal_file_size (struct inode *inode, +u64 minsize,u64 maxsize) +{ +u64 size =i_size_read (inode); +if (size < minsize || size > maxsize) + goto err; +if (size & ((1 << inode->i_blkbits) -1 )) + goto err; +return 0 ; +err: +gfs2_consist_inode (GFS2_I (inode)); +return -EIO ; +}extern void gfs2_set_iop (struct inode *inode); extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
fs/gfs2/ops_fstype.c +1 -1
@@ -586,7 +586,7 @@ static int map_journal_extents(struct gfs2_sbd *sdp) prev_db =0 ; -for (lb =0 ; lb < ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; lb++) { +for (lb =0 ; lb <i_size_read (jd->jd_inode) >> sdp->sd_sb.sb_bsize_shift; lb++) { bh.b_state =0 ; bh.b_blocknr =0 ; bh.b_size =1 << ip->i_inode.i_blkbits;
fs/gfs2/ops_inode.c +5 -5
@@ -406,7 +406,6 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, ip = ghs[1 ].gh_gl->gl_object; - ip->i_disksize = size;i_size_write (inode, size); error =gfs2_meta_inode_buffer (ip, &dibh);
@@ -461,7 +460,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) ip = ghs[1 ].gh_gl->gl_object; ip->i_inode.i_nlink =2 ; - ip->i_disksize = sdp->sd_sb.sb_bsize -sizeof (struct gfs2_dinode ); +i_size_write (inode, sdp->sd_sb.sb_bsize -sizeof (struct gfs2_dinode )); ip->i_diskflags |=GFS2_DIF_JDATA ; ip->i_entries =2 ;
@@ -990,7 +989,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)struct gfs2_inode *ip =GFS2_I (dentry->d_inode);struct gfs2_holder i_gh;struct buffer_head *dibh; -unsigned int x; +unsigned int x, size;char *buf;int error;
@@ -1002,7 +1001,8 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)return NULL ; } -if (!ip->i_disksize) { + size = (unsigned int )i_size_read (&ip->i_inode); +if (size ==0 ) {gfs2_consist_inode (ip); buf =ERR_PTR (-EIO ); goto out;
@@ -1014,7 +1014,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) goto out; } - x = ip->i_disksize +1 ; + x = size +1 ; buf =kmalloc (x,GFP_NOFS );if (!buf) buf =ERR_PTR (-ENOMEM );
fs/gfs2/quota.c +5 -8
@@ -735,10 +735,8 @@ get_a_page: goto out; size = loc +sizeof (struct gfs2_quota ); -if (size > inode->i_size) { - ip->i_disksize = size; +if (size > inode->i_size)i_size_write (inode, size); - } inode->i_mtime = inode->i_atime =CURRENT_TIME ;gfs2_trans_add_bh (ip->i_gl, dibh,1 );gfs2_dinode_out (ip, dibh->b_data);
@@ -1190,18 +1188,17 @@ static void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *int gfs2_quota_init (struct gfs2_sbd *sdp) {struct gfs2_inode *ip =GFS2_I (sdp->sd_qc_inode); -unsigned int blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; +u64 size =i_size_read (sdp->sd_qc_inode); +unsigned int blocks = size >> sdp->sd_sb.sb_bsize_shift;unsigned int x, slot =0 ;unsigned int found =0 ;u64 dblock;u32 extlen =0 ;int error; -if (!ip->i_disksize || ip->i_disksize > (64 <<20 ) || - ip->i_disksize & (sdp->sd_sb.sb_bsize -1 )) { -gfs2_consist_inode (ip); +if (gfs2_check_internal_file_size (sdp->sd_qc_inode,1 ,64 <<20 ))return -EIO ; - } + sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block; sdp->sd_quota_chunks =DIV_ROUND_UP (sdp->sd_quota_slots,8 *PAGE_SIZE );
fs/gfs2/rgrp.c +3 -3
@@ -500,7 +500,7 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)for (rgrps =0 ;; rgrps++) {loff_t pos = rgrps *sizeof (struct gfs2_rindex ); -if (pos +sizeof (struct gfs2_rindex ) >= ip->i_disksize) +if (pos +sizeof (struct gfs2_rindex ) >=i_size_read (inode))break ; error =gfs2_internal_read (ip, &ra_state, buf, &pos,sizeof (struct gfs2_rindex ));
@@ -588,7 +588,7 @@ 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 rgrp_count = ip->i_disksize; +u64 rgrp_count =i_size_read (inode);int error;do_div (rgrp_count,sizeof (struct gfs2_rindex ));
@@ -628,7 +628,7 @@ static int gfs2_ri_update_special(struct gfs2_inode *ip)for (sdp->sd_rgrps =0 ;; sdp->sd_rgrps++) {/* Ignore partials */ if ((sdp->sd_rgrps +1 ) *sizeof (struct gfs2_rindex ) > - ip->i_disksize) +i_size_read (inode))break ; error =read_rindex_entry (ip, &ra_state);if (error) {
fs/gfs2/super.c +5 -6
@@ -342,15 +342,14 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd) {struct gfs2_inode *ip =GFS2_I (jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode); +u64 size =i_size_read (jd->jd_inode); -if (ip->i_disksize < (8 <<20 ) || ip->i_disksize > (1 <<30 ) || - (ip->i_disksize & (sdp->sd_sb.sb_bsize -1 ))) { -gfs2_consist_inode (ip); +if (gfs2_check_internal_file_size (jd->jd_inode,8 <<20 ,1 <<30 ))return -EIO ; - } - jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; -if (gfs2_write_alloc_required (ip,0 , ip->i_disksize)) { + jd->jd_blocks = size >> sdp->sd_sb.sb_bsize_shift; + +if (gfs2_write_alloc_required (ip,0 , size)) {gfs2_consist_inode (ip);return -EIO ; }
Signature · 1 line
1.7.1.1
PATCH 3/22 GFS2: No longer experimental
In reply to Steven WhitehouseI think the time has arrvied to remove the experimental tag from GFS2.
fs/gfs2/Kconfig +1 -1
@@ -1,6 +1,6 @@ config GFS2_FS tristate "GFS2 file system support" - depends on EXPERIMENTAL && (64BIT || LBDAF) + depends on (64BIT || LBDAF) select DLM if GFS2_FS_LOCKING_DLM select CONFIGFS_FS if GFS2_FS_LOCKING_DLM select SYSFS if GFS2_FS_LOCKING_DLM
Signature · 1 line
1.7.1.1
PATCH 4/22 GFS2: Add a bug trap in allocation code
In reply to Steven WhitehouseThis adds a check to ensure that if we reach the block allocator that we don't try and proceed if there is no alloc structure hanging off the inode. This should only happen if there is a bug in GFS2. The error return code is distinctive in order that it will be easily spotted.
fs/gfs2/rgrp.c +9 -1
@@ -1496,11 +1496,19 @@ int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n)struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);struct buffer_head *dibh;struct gfs2_alloc *al = ip->i_alloc; -struct gfs2_rgrpd *rgd = al->al_rgd; +struct gfs2_rgrpd *rgd;u32 goal, blk;u64 block;int error; +/* Only happens if there is a bug in gfs2, return something distinctive +* to ensure that it is noticed. +*/ +if (al ==NULL ) +return -ECANCELED ; + + rgd = al->al_rgd; +if (rgrp_contains_block (rgd, ip->i_goal)) goal = ip->i_goal - rgd->rd_data0;else
Signature · 1 line
1.7.1.1
PATCH 5/22 GFS2: fallocate support
In reply to Steven WhitehouseFrom: Benjamin Marzinski <[email protected]>
This patch adds support for fallocate to gfs2. Since the gfs2 does not support uninitialized data blocks, it must write out zeros to all the blocks. However, since it does not need to lock any pages to read from, gfs2 can write out the zero blocks much more efficiently. On a moderately full filesystem, fallocate works around 5 times faster on average. The fallocate call also allows gfs2 to add blocks to the file without changing the filesize, which will make it possible for gfs2 to preallocate space for the rindex file, so that gfs2 can grow a completely full filesystem.
fs/gfs2/aops.c +2 -2
@@ -36,8 +36,8 @@#include "glops.h" -static void gfs2_page_add_databufs (struct gfs2_inode *ip,struct page *page, -unsigned int from,unsigned int to) +void gfs2_page_add_databufs (struct gfs2_inode *ip,struct page *page, +unsigned int from,unsigned int to) {struct buffer_head *head =page_buffers (page);unsigned int bsize = head->b_size;
fs/gfs2/incore.h +1 -0
@@ -571,6 +571,7 @@ struct gfs2_sbd {struct list_head sd_rindex_mru_list;struct gfs2_rgrpd *sd_rindex_forward;unsigned int sd_rgrps; +unsigned int sd_max_rg_data;/* Journal index stuff */
fs/gfs2/inode.h +2 -0
@@ -19,6 +19,8 @@ extern int gfs2_releasepage(struct page *page, gfp_t gfp_mask);extern int gfs2_internal_read (struct gfs2_inode *ip,struct file_ra_state *ra_state,char *buf,loff_t *pos,unsigned size); +extern void gfs2_page_add_databufs (struct gfs2_inode *ip,struct page *page, +unsigned int from,unsigned int to);extern void gfs2_set_aops (struct inode *inode);static inline int gfs2_is_stuffed (const struct gfs2_inode *ip)
fs/gfs2/ops_inode.c +254 -0
272 lines not on this page · raw message
fs/gfs2/rgrp.c +12 -0
@@ -589,6 +589,8 @@ static int gfs2_ri_update(struct gfs2_inode *ip)struct inode *inode = &ip->i_inode;struct file_ra_state ra_state;u64 rgrp_count =i_size_read (inode); +struct gfs2_rgrpd *rgd; +unsigned int max_data =0 ;int error;do_div (rgrp_count,sizeof (struct gfs2_rindex ));
@@ -603,6 +605,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip) } } +list_for_each_entry (rgd, &sdp->sd_rindex_list, rd_list) +if (rgd->rd_data > max_data) + max_data = rgd->rd_data; + sdp->sd_max_rg_data = max_data; sdp->sd_rindex_uptodate =1 ;return 0 ; }
@@ -622,6 +628,8 @@ 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; +struct gfs2_rgrpd *rgd; +unsigned int max_data =0 ;int error;file_ra_state_init (&ra_state, inode->i_mapping);
@@ -636,6 +644,10 @@ static int gfs2_ri_update_special(struct gfs2_inode *ip)return error; } } +list_for_each_entry (rgd, &sdp->sd_rindex_list, rd_list) +if (rgd->rd_data > max_data) + max_data = rgd->rd_data; + sdp->sd_max_rg_data = max_data; sdp->sd_rindex_uptodate =1 ;return 0 ;
fs/gfs2/trans.h +1 -0
@@ -20,6 +20,7 @@ struct gfs2_glock;#define RES_JDATA 1#define RES_DATA 1#define RES_LEAF 1 +#define RES_RG_HDR 1#define RES_RG_BIT 2#define RES_EATTR 1#define RES_STATFS 1
Signature · 1 line
1.7.1.1
PATCH 6/22 GFS2: Fix whitespace in previous patch
In reply to Steven WhitehouseRemoves the offending space
fs/gfs2/ops_inode.c +1 -1
@@ -1423,7 +1423,7 @@ static void calc_max_reserv(struct gfs2_inode *ip, loff_t max, loff_t *len, max_data -= tmp; }/* This calculation isn't the exact reverse of gfs2_write_calc_reserve, -so it might end up with fewer data blocks */ +so it might end up with fewer data blocks */ if (max_data <= *data_blocks)return ; *data_blocks = max_data;
Signature · 1 line
1.7.1.1
PATCH 7/22 GFS2: Don't enforce min hold time when two demotes occur in rapid succession
In reply to Steven WhitehouseDue to the design of the VFS, it is quite usual for operations on GFS2 to consist of a lookup (requiring a shared lock) followed by an operation requiring an exclusive lock. If a remote node has cached an exclusive lock, then it will receive two demote events in rapid succession firstly for a shared lock and then to unlocked. The existing min hold time code was triggering in this case, even if the node was otherwise idle since the state change time was being updated by the initial demote.
This patch introduces logic to skip the min hold timer in the case that a "double demote" of this kind has occurred. The min hold timer will still be used in all other cases.
A new glock flag is introduced which is used to keep track of whether there have been any newly queued holders since the last glock state change. The min hold time is only applied if the flag is set.
fs/gfs2/glock.c +11 -4
@@ -441,6 +441,8 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)else gfs2_glock_put_nolock (gl); } +if (held1 && held2 &&list_empty (&gl->gl_holders)) +clear_bit (GLF_QUEUED , &gl->gl_flags); gl->gl_state = new_state; gl->gl_tchange = jiffies;
@@ -1012,6 +1014,7 @@ fail:if (unlikely ((gh->gh_flags &LM_FLAG_PRIORITY ) && !insert_pt)) insert_pt = &gh2->gh_list; } +set_bit (GLF_QUEUED , &gl->gl_flags);if (likely (insert_pt ==NULL )) {list_add_tail (&gh->gh_list, &gl->gl_holders);if (unlikely (gh->gh_flags &LM_FLAG_PRIORITY ))
@@ -1310,10 +1313,12 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)gfs2_glock_hold (gl); holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; -if (time_before (now, holdtime)) - delay = holdtime - now; -if (test_bit (GLF_REPLY_PENDING , &gl->gl_flags)) - delay = gl->gl_ops->go_min_hold_time; +if (test_bit (GLF_QUEUED , &gl->gl_flags)) { +if (time_before (now, holdtime)) + delay = holdtime - now; +if (test_bit (GLF_REPLY_PENDING , &gl->gl_flags)) + delay = gl->gl_ops->go_min_hold_time; + }spin_lock (&gl->gl_spin);handle_callback (gl, state, delay);
@@ -1660,6 +1665,8 @@ static const char *gflags2str(char *buf, const unsigned long *gflags) *p++ ='I' ;if (test_bit (GLF_FROZEN , gflags)) *p++ ='F' ; +if (test_bit (GLF_QUEUED , gflags)) + *p++ ='q' ; *p =0 ;return buf; }
fs/gfs2/incore.h +1 -0
@@ -196,6 +196,7 @@ enum {GLF_REPLY_PENDING =9 ,GLF_INITIAL =10 ,GLF_FROZEN =11 , + GLF_QUEUED = 12, }; struct gfs2_glock {
fs/gfs2/trace_gfs2.h +2 -1
@@ -39,7 +39,8 @@ {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \ {(1UL << GLF_REPLY_PENDING), "r" }, \ {(1UL << GLF_INITIAL), "I" }, \ - {(1UL << GLF_FROZEN), "F" }) + {(1UL << GLF_FROZEN), "F" }, \ + {(1UL << GLF_QUEUED), "q" }) #ifndef NUMPTY #define NUMPTY
Signature · 1 line
1.7.1.1
PATCH 8/22 GFS2: Update handling of DLM return codes to match reality
In reply to Steven WhitehouseGFS2's idea of which return codes it needs to handle was based upon those listed in dlm.h. Those didn't cover all the possible codes and listed some which never happen. This updates GFS2 to handle all the codes which can actually be returned from the DLM under various circumstances.
fs/gfs2/lock_dlm.c +2 -2
@@ -42,9 +42,9 @@ static void gdlm_ast(void *arg) ret |=LM_OUT_CANCELED ; goto out;case -EAGAIN :/* Try lock fails */ +case -EDEADLK :/* Deadlock detected */ goto out; -case -EINVAL :/* Invalid */ -case -ENOMEM :/* Out of memory */ +case -ETIMEDOUT :/* Canceled due to timeout */ ret |=LM_OUT_ERROR ; goto out;case 0 :/* Success */
Signature · 1 line
1.7.1.1
PATCH 9/22 GFS2: Use new workqueue scheme
In reply to Steven WhitehouseThe recovery workqueue can be freezable since
we want it to finish what it is doing if the system is to be frozen (although why you'd want to freeze a cluster node is beyond me since it will result in it being ejected from the cluster). It does still make sense for single node GFS2 filesystems though.
The glock workqueue will benefit from being able to run more work items concurrently. A test running postmark shows improved performance and multi-threaded workloads are likely to benefit even more. It needs to be high priority because the latency directly affects the latency of filesystem glock operations.
The delete workqueue is similar to the recovery workqueue in that it must not get blocked by memory allocations, and may run for a long time.
Potentially other GFS2 threads might also be converted to workqueues, but I'll leave that for a later patch.
fs/gfs2/glock.c +4 -2
@@ -1783,10 +1783,12 @@ int __init gfs2_glock_init(void) }#endif - glock_workqueue =create_workqueue ("glock_workqueue" ); + glock_workqueue =alloc_workqueue ("glock_workqueue" ,WQ_RESCUER | +WQ_HIGHPRI |WQ_FREEZEABLE ,0 );if (IS_ERR (glock_workqueue))return PTR_ERR (glock_workqueue); - gfs2_delete_workqueue =create_workqueue ("delete_workqueue" ); + gfs2_delete_workqueue =alloc_workqueue ("delete_workqueue" ,WQ_RESCUER | +WQ_FREEZEABLE ,0 );if (IS_ERR (gfs2_delete_workqueue)) {destroy_workqueue (glock_workqueue);return PTR_ERR (gfs2_delete_workqueue);
fs/gfs2/main.c +1 -1
@@ -140,7 +140,7 @@ static int __init init_gfs2_fs(void) error = -ENOMEM ; gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_RESCUER |WQ_FREEZEABLE ,0 );if (!gfs_recovery_wq) goto fail_wq;
Signature · 1 line
1.7.1.1
PATCH 10/22 GFS2: Make . and .. qstrs constant
In reply to Steven WhitehouseRather than calculating the qstrs for . and .. each time we need them, its better to keep a constant version of these and just refer to them when required.
fs/gfs2/dir.c +3 -0
@@ -79,6 +79,9 @@#define gfs2_disk_hash2offset (h) (((u64)(h)) >> 1)#define gfs2_dir_offset2hash (p) ((u32)(((u64)(p)) << 1)) +struct qstr gfs2_qdot__read_mostly ; +struct qstr gfs2_qdotdot__read_mostly ; +typedef int (*leaf_call_t ) (struct gfs2_inode *dip,u32 index,u32 len,u64 leaf_no,void *data); typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent,
fs/gfs2/dir.h +19 -15
@@ -17,23 +17,24 @@ struct inode;struct gfs2_inode ;struct gfs2_inum ; -struct inode *gfs2_dir_search (struct inode *dir,const struct qstr *filename); -int gfs2_dir_check (struct inode *dir,const struct qstr *filename, -const struct gfs2_inode *ip); -int gfs2_dir_add (struct inode *inode,const struct qstr *filename, -const struct gfs2_inode *ip,unsigned int type); -int gfs2_dir_del (struct gfs2_inode *dip,const struct qstr *filename); -int gfs2_dir_read (struct inode *inode,u64 *offset,void *opaque, -filldir_t filldir); -int gfs2_dir_mvino (struct gfs2_inode *dip,const struct qstr *filename, -const struct gfs2_inode *nip,unsigned int new_type); +extern struct inode *gfs2_dir_search (struct inode *dir, +const struct qstr *filename); +extern int gfs2_dir_check (struct inode *dir,const struct qstr *filename, +const struct gfs2_inode *ip); +extern int gfs2_dir_add (struct inode *inode,const struct qstr *filename, +const struct gfs2_inode *ip,unsigned int type); +extern int gfs2_dir_del (struct gfs2_inode *dip,const struct qstr *filename); +extern int gfs2_dir_read (struct inode *inode,u64 *offset,void *opaque, +filldir_t filldir); +extern int gfs2_dir_mvino (struct gfs2_inode *dip,const struct qstr *filename, +const struct gfs2_inode *nip,unsigned int new_type); -int gfs2_dir_exhash_dealloc (struct gfs2_inode *dip); +extern int gfs2_dir_exhash_dealloc (struct gfs2_inode *dip); -int gfs2_diradd_alloc_required (struct inode *dir, -const struct qstr *filename); -int gfs2_dir_get_new_buffer (struct gfs2_inode *ip,u64 block, -struct buffer_head **bhp); +extern int gfs2_diradd_alloc_required (struct inode *dir, +const struct qstr *filename); +extern int gfs2_dir_get_new_buffer (struct gfs2_inode *ip,u64 block, +struct buffer_head **bhp);static inline u32 gfs2_disk_hash (const char *data,int len) {
@@ -61,4 +62,7 @@ static inline void gfs2_qstr2dirent(const struct qstr *name, u16 reclen, struct memcpy(dent + 1, name->name, name->len); } +extern struct qstr gfs2_qdot; +extern struct qstr gfs2_qdotdot; +#endif /* __DIR_DOT_H__ */
fs/gfs2/export.c +1 -8
@@ -126,16 +126,9 @@ static int gfs2_get_name(struct dentry *parent, char *name,static struct dentry *gfs2_get_parent (struct dentry *child) { -struct qstr dotdot;struct dentry *dentry; -/* -* XXX(hch): it would be a good idea to keep this around as a -* static variable. -*/ -gfs2_str2qstr (&dotdot,".." ); - - dentry =d_obtain_alias (gfs2_lookupi (child->d_inode, &dotdot,1 )); + dentry =d_obtain_alias (gfs2_lookupi (child->d_inode, &gfs2_qdotdot,1 ));if (!IS_ERR (dentry)) dentry->d_op = &gfs2_dops;return dentry;
fs/gfs2/main.c +4 -0
@@ -24,6 +24,7 @@#include "glock.h" #include "quota.h" #include "recovery.h" +#include "dir.h" static struct shrinker qd_shrinker = { .shrink = gfs2_shrink_qd_memory,
@@ -78,6 +79,9 @@ static int __init init_gfs2_fs(void) {int error; +gfs2_str2qstr (&gfs2_qdot,"." ); +gfs2_str2qstr (&gfs2_qdotdot,".." ); + error =gfs2_sys_init ();if (error)return error;
fs/gfs2/ops_inode.c +6 -18
@@ -471,18 +471,15 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)if (!gfs2_assert_withdraw (sdp, !error)) {struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data;struct gfs2_dirent *dent = (struct gfs2_dirent *)(di+1 ); -struct qstr str; -gfs2_str2qstr (&str,"." );gfs2_trans_add_bh (ip->i_gl, dibh,1 ); -gfs2_qstr2dirent (&str,GFS2_DIRENT_SIZE (str.len), dent); +gfs2_qstr2dirent (&gfs2_qdot,GFS2_DIRENT_SIZE (gfs2_qdot.len), dent); dent->de_inum = di->di_num;/* already GFS2 endian */ dent->de_type =cpu_to_be16 (DT_DIR ); di->di_entries =cpu_to_be32 (1 ); -gfs2_str2qstr (&str,".." ); dent = (struct gfs2_dirent *)((char *)dent +GFS2_DIRENT_SIZE (1 )); -gfs2_qstr2dirent (&str, dibh->b_size -GFS2_DIRENT_SIZE (1 ) -sizeof (struct gfs2_dinode ), dent); +gfs2_qstr2dirent (&gfs2_qdotdot, dibh->b_size -GFS2_DIRENT_SIZE (1 ) -sizeof (struct gfs2_dinode ), dent);gfs2_inum_out (dip, dent); dent->de_type =cpu_to_be16 (DT_DIR );
@@ -523,7 +520,6 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)static int gfs2_rmdiri (struct gfs2_inode *dip,const struct qstr *name,struct gfs2_inode *ip) { -struct qstr dotname;int error;if (ip->i_entries !=2 ) {
@@ -540,13 +536,11 @@ static int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,if (error)return error; -gfs2_str2qstr (&dotname,"." ); - error =gfs2_dir_del (ip, &dotname); + error =gfs2_dir_del (ip, &gfs2_qdot);if (error)return error; -gfs2_str2qstr (&dotname,".." ); - error =gfs2_dir_del (ip, &dotname); + error =gfs2_dir_del (ip, &gfs2_qdotdot);if (error)return error;
@@ -695,11 +689,8 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)struct inode *dir = &to->i_inode;struct super_block *sb = dir->i_sb;struct inode *tmp; -struct qstr dotdot;int error =0 ; -gfs2_str2qstr (&dotdot,".." ); -igrab (dir);for (;;) {
@@ -712,7 +703,7 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)break ; } - tmp =gfs2_lookupi (dir, &dotdot,1 ); + tmp =gfs2_lookupi (dir, &gfs2_qdotdot,1 );if (IS_ERR (tmp)) { error =PTR_ERR (tmp);break ;
@@ -921,9 +912,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, }if (dir_rename) { -struct qstr name; -gfs2_str2qstr (&name,".." ); - error =gfs2_change_nlink (ndip,+1 );if (error) goto out_end_trans;
@@ -931,7 +919,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,if (error) goto out_end_trans; - error =gfs2_dir_mvino (ip, &name, ndip,DT_DIR ); + error =gfs2_dir_mvino (ip, &gfs2_qdotdot, ndip,DT_DIR );if (error) goto out_end_trans; }else {
Signature · 1 line
1.7.1.1
PATCH 11/22 GFS2: Remove ignore_local_fs mount argument
In reply to Steven WhitehouseThis is been a no-op for a very long time now. I'm pretty sure nobody uses it, but just in case we'll still accept it on the command line, but ignore it.
fs/gfs2/incore.h +0 -1
@@ -416,7 +416,6 @@ struct gfs2_args {char ar_locktable[GFS2_LOCKNAME_LEN ];/* Name of the Lock Table */ char ar_hostdata[GFS2_LOCKNAME_LEN ];/* Host specific data */ unsigned int ar_spectator:1; /* Don't get a journal */ - unsigned int ar_ignore_local_fs:1; /* Ignore optimisations */ unsigned int ar_localflocks:1; /* Let the VFS do flock|fcntl */ unsigned int ar_localcaching:1; /* Local caching */ unsigned int ar_debug:1; /* Oops on errors */
fs/gfs2/super.c +1 -4
@@ -159,7 +159,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) args->ar_spectator =1 ;break ;case Opt_ignore_local_fs: - args->ar_ignore_local_fs =1 ; +/* Retained for backwards compat only */ break ;case Opt_localflocks: args->ar_localflocks =1 ;
@@ -1128,7 +1128,6 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)/* Some flags must not be changed */ if (args_neq (&args, &sdp->sd_args, spectator) || -args_neq (&args, &sdp->sd_args, ignore_local_fs) ||args_neq (&args, &sdp->sd_args, localflocks) ||args_neq (&args, &sdp->sd_args, localcaching) ||args_neq (&args, &sdp->sd_args, meta))
@@ -1233,8 +1232,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",hostdata=%s" , args->ar_hostdata);if (args->ar_spectator)seq_printf (s,",spectator" ); -if (args->ar_ignore_local_fs) -seq_printf (s,",ignore_local_fs" );if (args->ar_localflocks)seq_printf (s,",localflocks" );if (args->ar_localcaching)
Signature · 1 line
1.7.1.1
PATCH 12/22 GFS2: Remove localcaching mount option
In reply to Steven WhitehouseThis option defaulted to on for lock_nolock mounts and off otherwise. The only function was to avoid the revalidation of dentries. In the cluster case, that is entirely pointless and liable to cause coherency problems.
The patch changes the revalidation to depend upon whether the fs is a local or cluster fs (i.e. it follows the existing default behaviour). I very much doubt anybody ever used this option as there is no reason to. Even so we will continue to accept it on the mount command line, but ignore it.
fs/gfs2/dentry.c +1 -1
@@ -49,7 +49,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) ip =GFS2_I (inode); } -if (sdp->sd_args.ar_localcaching) +if (sdp->sd_lockstruct.ls_ops->lm_mount ==NULL ) goto valid; had_lock = (gfs2_glock_is_locked_by_me (dip->i_gl) !=NULL );
fs/gfs2/incore.h +0 -1
@@ -417,7 +417,6 @@ struct gfs2_args {char ar_hostdata[GFS2_LOCKNAME_LEN ];/* Host specific data */ unsigned int ar_spectator:1; /* Don't get a journal */ unsigned int ar_localflocks:1; /* Let the VFS do flock|fcntl */ - unsigned int ar_localcaching:1; /* Local caching */ unsigned int ar_debug:1; /* Oops on errors */ unsigned int ar_upgrade:1; /* Upgrade ondisk format */ unsigned int ar_posix_acl:1; /* Enable posix acls */
fs/gfs2/ops_fstype.c +0 -1
@@ -1022,7 +1022,6 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)if (!strcmp ("lock_nolock" , proto)) { lm = &nolock_ops; sdp->sd_args.ar_localflocks =1 ; - sdp->sd_args.ar_localcaching =1 ; #ifdef CONFIG_GFS2_FS_LOCKING_DLM }else if (!strcmp ("lock_dlm" , proto)) { lm = &gfs2_dlm_ops;
fs/gfs2/super.c +1 -4
@@ -165,7 +165,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) args->ar_localflocks =1 ;break ;case Opt_localcaching: - args->ar_localcaching =1 ; +/* Retained for backwards compat only */ break ;case Opt_debug:if (args->ar_errors ==GFS2_ERRORS_PANIC ) {
@@ -1129,7 +1129,6 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)/* Some flags must not be changed */ if (args_neq (&args, &sdp->sd_args, spectator) ||args_neq (&args, &sdp->sd_args, localflocks) || -args_neq (&args, &sdp->sd_args, localcaching) ||args_neq (&args, &sdp->sd_args, meta))return -EINVAL ;
@@ -1234,8 +1233,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",spectator" );if (args->ar_localflocks)seq_printf (s,",localflocks" ); -if (args->ar_localcaching) -seq_printf (s,",localcaching" );if (args->ar_debug)seq_printf (s,",debug" );if (args->ar_upgrade)
Signature · 1 line
1.7.1.1
PATCH 13/22 GFS2: Remove upgrade mount option
In reply to Steven WhitehouseThis option has never done anything useful. Also at the same time this cleans up the sb checks which are done at mount time. The debug option will be accepted, but ignored in future. Since it didn't do anything, there didn't seem much point in retaining it.
fs/gfs2/incore.h +0 -1
@@ -418,7 +418,6 @@ struct gfs2_args { unsigned int ar_spectator:1; /* Don't get a journal */ unsigned int ar_localflocks:1; /* Let the VFS do flock|fcntl */ unsigned int ar_debug:1; /* Oops on errors */ - unsigned int ar_upgrade:1; /* Upgrade ondisk format */ unsigned int ar_posix_acl:1; /* Enable posix acls */ unsigned int ar_quota:2; /* off/account/on */ unsigned int ar_suiddir:1; /* suiddir support */
fs/gfs2/ops_fstype.c +2 -58
79 lines not on this page · raw message
fs/gfs2/super.c +1 -3
@@ -179,7 +179,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) args->ar_debug =0 ;break ;case Opt_upgrade: - args->ar_upgrade =1 ; +/* Retained for backwards compat only */ break ;case Opt_acl: args->ar_posix_acl =1 ;
@@ -1235,8 +1235,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",localflocks" );if (args->ar_debug)seq_printf (s,",debug" ); -if (args->ar_upgrade) -seq_printf (s,",upgrade" );if (args->ar_posix_acl)seq_printf (s,",acl" );if (args->ar_quota !=GFS2_QUOTA_DEFAULT ) {
Signature · 1 line
1.7.1.1
PATCH 14/22 GFS2: Fix journal check for spectator mounts
In reply to Steven WhitehouseWhen checking journals for spectator mounts, we cannot rely on the journal being locked, whatever its jid might be. This patch ensures that we always get the journal locks when checking journals for a spectator mount.
fs/gfs2/recovery.c +2 -1
@@ -456,7 +456,8 @@ void gfs2_recover_func(struct work_struct *work)unsigned int pass;int error; -if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) { +if (sdp->sd_args.ar_spectator || + (jd->jd_jid != sdp->sd_lockstruct.ls_jid)) {fs_info (sdp,"jid=%u: Trying to acquire journal lock...\n" , jd->jd_jid);
Signature · 1 line
1.7.1.1
PATCH 15/22 GFS2: reserve more blocks for transactions
In reply to Steven WhitehouseFrom: Benjamin Marzinski <[email protected]>
Some of the functions in GFS2 were not reserving space in the transaction for the resource group header and the resource groups bitblocks that get added when you do allocation. GFS2 now makes sure to reserve space for the resource group header and either all the bitblocks in the resource group, or one for each block that it may allocate, whichever is smaller using the new gfs2_rg_blocks() inline function.
fs/gfs2/aops.c +2 -0
@@ -663,6 +663,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, rblocks +=RES_STATFS +RES_QUOTA ;if (&ip->i_inode == sdp->sd_rindex) rblocks +=2 *RES_STATFS ; +if (alloc_required) + rblocks +=gfs2_rg_blocks (al); error =gfs2_trans_begin (sdp, rblocks,PAGE_CACHE_SIZE /sdp->sd_sb.sb_bsize);
fs/gfs2/bmap.c +1 -1
@@ -1151,7 +1151,7 @@ static int do_grow(struct inode *inode, u64 size) goto do_grow_qunlock; } - error =gfs2_trans_begin (sdp,RES_DINODE +1 ,0 ); + error =gfs2_trans_begin (sdp,RES_DINODE +RES_STATFS +RES_RG_BIT ,0 );if (error) goto do_grow_release;
fs/gfs2/file.c +3 -1
@@ -382,8 +382,10 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) rblocks =RES_DINODE + ind_blocks;if (gfs2_is_jdata (ip)) rblocks += data_blocks ? data_blocks :1 ; -if (ind_blocks || data_blocks) +if (ind_blocks || data_blocks) { rblocks +=RES_STATFS +RES_QUOTA ; + rblocks +=gfs2_rg_blocks (al); + } ret =gfs2_trans_begin (sdp, rblocks,0 );if (ret) goto out_trans_fail;
fs/gfs2/ops_inode.c +3 -3
@@ -219,7 +219,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, goto out_gunlock_q; error =gfs2_trans_begin (sdp, sdp->sd_max_dirres + - al->al_rgd->rd_length + +gfs2_rg_blocks (al) +2 *RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error)
@@ -884,7 +884,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, goto out_gunlock_q; error =gfs2_trans_begin (sdp, sdp->sd_max_dirres + - al->al_rgd->rd_length + +gfs2_rg_blocks (al) +4 *RES_DINODE +4 *RES_LEAF +RES_STATFS +RES_QUOTA +4 ,0 );if (error)
@@ -1481,7 +1481,7 @@ retry: al->al_requested = data_blocks + ind_blocks; rblocks =RES_DINODE + ind_blocks +RES_STATFS +RES_QUOTA + -RES_RG_HDR + ip->i_alloc->al_rgd->rd_length; +RES_RG_HDR +gfs2_rg_blocks (al);if (gfs2_is_jdata (ip)) rblocks += data_blocks ? data_blocks :1 ;
fs/gfs2/quota.c +2 -1
@@ -815,7 +815,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) goto out_alloc;if (nalloc) - blocks += al->al_rgd->rd_length + nalloc * ind_blocks +RES_STATFS ; + blocks +=gfs2_rg_blocks (al) + nalloc * ind_blocks +RES_STATFS ; error =gfs2_trans_begin (sdp, blocks,0 );if (error)
@@ -1586,6 +1586,7 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, error =gfs2_inplace_reserve (ip);if (error) goto out_alloc; + blocks +=gfs2_rg_blocks (al); } error =gfs2_trans_begin (sdp, blocks +RES_DINODE +1 ,0 );
fs/gfs2/trans.h +8 -0
@@ -26,6 +26,14 @@ struct gfs2_glock;#define RES_STATFS 1#define RES_QUOTA 2 +/* reserve either the number of blocks to be allocated plus the rg header +* block, or all of the blocks in the rg, whichever is smaller */ +static inline unsigned int gfs2_rg_blocks (const struct gfs2_alloc *al) +{ +return (al->al_requested < al->al_rgd->rd_length)? + al->al_requested +1 : al->al_rgd->rd_length; +} +int gfs2_trans_begin (struct gfs2_sbd *sdp,unsigned int blocks,unsigned int revokes);
fs/gfs2/xattr.c +1 -1
@@ -734,7 +734,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, goto out_gunlock_q; error =gfs2_trans_begin (GFS2_SB (&ip->i_inode), - blks + al->al_rgd->rd_length + + blks +gfs2_rg_blocks (al) +RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error) goto out_ipres;
Signature · 1 line
1.7.1.1
PATCH 16/22 GFS2: Fix compiler warning from previous patch
In reply to Steven WhitehouseThis shouldn't really be required, but gcc can't tell that "al" is only accessed when initialised.
fs/gfs2/aops.c +1 -1
@@ -615,7 +615,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,unsigned int data_blocks =0 , ind_blocks =0 , rblocks;int alloc_required;int error =0 ; -struct gfs2_alloc *al; +struct gfs2_alloc *al =NULL ;pgoff_t index = pos >>PAGE_CACHE_SHIFT ;unsigned from = pos & (PAGE_CACHE_SIZE -1 );unsigned to = from + len;
Signature · 1 line
1.7.1.1
PATCH 17/22 GFS2: Fix spectator umount issue
In reply to Steven WhitehouseThe tests further down the recovery function relating to unlocking the journal need to be updated to match the intial test. Also, a test in the umount code which was surplus to requirements has been removed. Umounting spectator mounts now works correctly, as expected.
fs/gfs2/glock.c +1 -1
@@ -1517,7 +1517,7 @@ static void clear_glock(struct gfs2_glock *gl)spin_unlock (&lru_lock);spin_lock (&gl->gl_spin); -if (find_first_holder (gl) ==NULL && gl->gl_state !=LM_ST_UNLOCKED ) +if (gl->gl_state !=LM_ST_UNLOCKED )handle_callback (gl,LM_ST_UNLOCKED ,0 );spin_unlock (&gl->gl_spin);gfs2_glock_hold (gl);
fs/gfs2/recovery.c +6 -6
@@ -455,12 +455,13 @@ void gfs2_recover_func(struct work_struct *work)int ro =0 ;unsigned int pass;int error; +int jlocked =0 ;if (sdp->sd_args.ar_spectator || (jd->jd_jid != sdp->sd_lockstruct.ls_jid)) {fs_info (sdp,"jid=%u: Trying to acquire journal lock...\n" , jd->jd_jid); - + jlocked =1 ;/* Acquire the journal lock so we can do recovery */ error = gfs2_glock_nq_num(sdp, jd->jd_jid, &gfs2_journal_glops,
@@ -555,13 +556,12 @@ void gfs2_recover_func(struct work_struct *work) jd->jd_jid, t); } -if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) -gfs2_glock_dq_uninit (&ji_gh); -gfs2_recovery_done (sdp, jd->jd_jid,LM_RD_SUCCESS ); -if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) +if (jlocked) { +gfs2_glock_dq_uninit (&ji_gh);gfs2_glock_dq_uninit (&j_gh); + }fs_info (sdp,"jid=%u: Done\n" , jd->jd_jid); goto done;
@@ -569,7 +569,7 @@ void gfs2_recover_func(struct work_struct *work) fail_gunlock_tr:gfs2_glock_dq_uninit (&t_gh); fail_gunlock_ji: -if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) { +if (jlocked) {gfs2_glock_dq_uninit (&ji_gh); fail_gunlock_j:gfs2_glock_dq_uninit (&j_gh);
Signature · 1 line
1.7.1.1
PATCH 18/22 GFS2: Add "norecovery" mount option as a synonym for "spectator"
In reply to Steven WhitehouseXFS supports the "norecovery" mount option which is basically the same as the GFS2 spectator mode. This adds support for "norecovery" as a synonym for spectator mode, which is hopefully a more obvious description of what it actually does.
fs/gfs2/super.c +1 -0
@@ -85,6 +85,7 @@ static const match_table_t tokens = { {Opt_locktable, "locktable=%s"}, {Opt_hostdata, "hostdata=%s"}, {Opt_spectator, "spectator"}, + {Opt_spectator, "norecovery"}, {Opt_ignore_local_fs, "ignore_local_fs"}, {Opt_localflocks, "localflocks"}, {Opt_localcaching, "localcaching"},
Signature · 1 line
1.7.1.1
PATCH 19/22 GFS2: Improve journal allocation via sysfs
In reply to Steven WhitehouseRecently a feature was added to GFS2 to allow journal id allocation via sysfs. This patch builds upon that so that a negative journal id will be treated as an error code to be passed back as the return code from mount. This allows termination of the mount process if there is a failure.
Also, the process has been updated so that the kernel will wait for a journal id, even in the "spectator" case. This is required in order to avoid mounting a filesystem in case there is an error while joining the cluster. In the spectator case, 0 is written into the file to indicate that all is well, and that mount should continue.
fs/gfs2/incore.h +1 -1
@@ -494,7 +494,7 @@ struct gfs2_sb_host {*/ struct lm_lockstruct { -unsigned int ls_jid; +int ls_jid;unsigned int ls_first;unsigned int ls_first_done;unsigned int ls_nodir;
fs/gfs2/ops_fstype.c +14 -2
@@ -1056,8 +1056,6 @@ static int gfs2_journalid_wait(void *word)static int wait_on_journal (struct gfs2_sbd *sdp) { -if (sdp->sd_args.ar_spectator) -return 0 ;if (sdp->sd_lockstruct.ls_ops->lm_mount ==NULL )return 0 ;
@@ -1160,6 +1158,20 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silentif (error) goto fail_sb; +/* +* If user space has failed to join the cluster or some similar +* failure has occurred, then the journal id will contain a +* negative (error) number. This will then be returned to the +* caller (of the mount syscall). We do this even for spectator +* mounts (which just write a jid of 0 to indicate "ok" even though +* the jid is unused in the spectator case) +*/ +if (sdp->sd_lockstruct.ls_jid <0 ) { + error = sdp->sd_lockstruct.ls_jid; + sdp->sd_lockstruct.ls_jid =0 ; + goto fail_sb; + } + error =init_inodes (sdp,DO );if (error) goto fail_sb;
fs/gfs2/sys.c +9 -8
@@ -399,31 +399,32 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)static ssize_t jid_show (struct gfs2_sbd *sdp,char *buf) { -return sprintf (buf,"%u\n" , sdp->sd_lockstruct.ls_jid); +return sprintf (buf,"%d\n" , sdp->sd_lockstruct.ls_jid); }static ssize_t jid_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { -unsigned jid; +int jid;int rv; - rv =sscanf (buf,"%u" , &jid); + rv =sscanf (buf,"%d" , &jid);if (rv !=1 )return -EINVAL ;spin_lock (&sdp->sd_jindex_spin); rv = -EINVAL ; -if (sdp->sd_args.ar_spectator) - goto out;if (sdp->sd_lockstruct.ls_ops->lm_mount ==NULL ) goto out; rv = -EBUSY ; -if (test_and_clear_bit (SDF_NOJOURNALID , &sdp->sd_flags) ==0 ) +if (test_bit (SDF_NOJOURNALID , &sdp->sd_flags) ==0 ) goto out; + rv =0 ; +if (sdp->sd_args.ar_spectator && jid >0 ) + rv = jid = -EINVAL ; sdp->sd_lockstruct.ls_jid = jid; +clear_bit (SDF_NOJOURNALID , &sdp->sd_flags);smp_mb__after_clear_bit ();wake_up_bit (&sdp->sd_flags,SDF_NOJOURNALID ); - rv =0 ; out:spin_unlock (&sdp->sd_jindex_spin);return rv ? rv : len;
@@ -617,7 +618,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,add_uevent_var (env,"LOCKTABLE=%s" , sdp->sd_table_name);add_uevent_var (env,"LOCKPROTO=%s" , sdp->sd_proto_name);if (!test_bit (SDF_NOJOURNALID , &sdp->sd_flags)) -add_uevent_var (env,"JOURNALID=%u" , sdp->sd_lockstruct.ls_jid); +add_uevent_var (env,"JOURNALID=%d" , sdp->sd_lockstruct.ls_jid);if (gfs2_uuid_valid (uuid))add_uevent_var (env,"UUID=%pUB" , uuid);return 0 ;
Signature · 1 line
1.7.1.1
PATCH 20/22 GFS2 fatal: filesystem consistency error on rename
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
This patch fixes a GFS2 problem whereby the first rename after a mount can result in a file system consistency error being flagged improperly and cause the file system to withdraw. The problem is that the rename code tries to run the rgrp list with function gfs2_blk2rgrpd before the rgrp list is guaranteed to be read in from disk. The patch makes the rename function hold the rindex glock (as the gfs2_unlink code does today) which reads in the rgrp list if need be. There were a total of three places in the rename code that improperly referenced the rgrp list without the rindex glock and this patch fixes all three.
fs/gfs2/ops_inode.c +6 -2
@@ -736,7 +736,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,struct gfs2_inode *ip =GFS2_I (odentry->d_inode);struct gfs2_inode *nip =NULL ;struct gfs2_sbd *sdp =GFS2_SB (odir); -struct gfs2_holder ghs[5 ], r_gh = { .gh_gl =NULL , }; +struct gfs2_holder ghs[5 ], r_gh = { .gh_gl =NULL , }, ri_gh;struct gfs2_rgrpd *nrgd;unsigned int num_gh;int dir_rename =0 ;
@@ -750,6 +750,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,return 0 ; } + error =gfs2_rindex_hold (sdp, &ri_gh); +if (error) +return error;if (odip != ndip) { error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
@@ -879,7 +882,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, al->al_requested = sdp->sd_max_dirres; - error =gfs2_inplace_reserve (ndip); + error =gfs2_inplace_reserve_ri (ndip);if (error) goto out_gunlock_q;
@@ -961,6 +964,7 @@ out_gunlock_r:if (r_gh.gh_gl)gfs2_glock_dq_uninit (&r_gh); out: +gfs2_glock_dq_uninit (&ri_gh);return error; }
fs/gfs2/rgrp.c +13 -9
@@ -1200,7 +1200,8 @@ out:* Returns: errno */ -int gfs2_inplace_reserve_i (struct gfs2_inode *ip,char *file,unsigned int line) +int gfs2_inplace_reserve_i (struct gfs2_inode *ip,int hold_rindex, +char *file,unsigned int line) {struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);struct gfs2_alloc *al = ip->i_alloc;
@@ -1211,12 +1212,15 @@ int gfs2_inplace_reserve_i(struct gfs2_inode *ip, char *file, unsigned int line)return -EINVAL ; try_again: -/* 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_special (ip); +if (hold_rindex) { +/* 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_special (ip); + }if (error)return error;
@@ -1227,7 +1231,7 @@ try_again:try to free it, and try the allocation again. */ error =get_local_rgrp (ip, &unlinked, &last_unlinked);if (error) { -if (ip !=GFS2_I (sdp->sd_rindex)) +if (hold_rindex && ip !=GFS2_I (sdp->sd_rindex))gfs2_glock_dq_uninit (&al->al_ri_gh);if (error != -EAGAIN )return error;
@@ -1269,7 +1273,7 @@ void gfs2_inplace_release(struct gfs2_inode *ip) al->al_rgd =NULL ;if (al->al_rgd_gh.gh_gl)gfs2_glock_dq_uninit (&al->al_rgd_gh); -if (ip !=GFS2_I (sdp->sd_rindex)) +if (ip !=GFS2_I (sdp->sd_rindex) && al->al_ri_gh.gh_gl)gfs2_glock_dq_uninit (&al->al_ri_gh); }
fs/gfs2/rgrp.h +5 -3
@@ -39,10 +39,12 @@ static inline void gfs2_alloc_put(struct gfs2_inode *ip) ip->i_alloc =NULL ; } -extern int gfs2_inplace_reserve_i (struct gfs2_inode *ip,char *file, -unsigned int line); +extern int gfs2_inplace_reserve_i (struct gfs2_inode *ip,int hold_rindex, +char *file,unsigned int line);#define gfs2_inplace_reserve (ip) \ -gfs2_inplace_reserve_i((ip), __FILE__, __LINE__) + gfs2_inplace_reserve_i((ip), 1, __FILE__, __LINE__) +#define gfs2_inplace_reserve_ri (ip) \ + gfs2_inplace_reserve_i((ip), 0, __FILE__, __LINE__)extern void gfs2_inplace_release (struct gfs2_inode *ip);
Signature · 1 line
1.7.1.1
PATCH 21/22 GFS2: Fix type mapping for demote_rq interface
In reply to Steven WhitehouseMostly the glock operations follow the type of the glock. The one exception is the transaction glock, so we need to check for that directly.
fs/gfs2/glops.c +0 -1
@@ -452,7 +452,6 @@ const struct gfs2_glock_operations *gfs2_glops_list[] = { [LM_TYPE_META] = &gfs2_meta_glops, [LM_TYPE_INODE] = &gfs2_inode_glops, [LM_TYPE_RGRP] = &gfs2_rgrp_glops, - [LM_TYPE_NONDISK] = &gfs2_trans_glops, [LM_TYPE_IOPEN] = &gfs2_iopen_glops, [LM_TYPE_FLOCK] = &gfs2_flock_glops, [LM_TYPE_NONDISK] = &gfs2_nondisk_glops,
fs/gfs2/sys.c +4 -1
@@ -230,7 +230,10 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t lenif (gltype >LM_TYPE_JOURNAL )return -EINVAL ; - glops = gfs2_glops_list[gltype]; +if (gltype ==LM_TYPE_NONDISK && glnum ==GFS2_TRANS_LOCK ) + glops = &gfs2_trans_glops; +else + glops = gfs2_glops_list[gltype];if (glops ==NULL )return -EINVAL ;if (!test_and_set_bit (SDF_DEMOTE , &sdp->sd_flags))
Signature · 1 line
1.7.1.1
PATCH 22/22 GFS2: fixed typo
In reply to Steven WhitehouseFrom: Andrea Gelmini <[email protected]>
fs/gfs2/glock.h +1 -1
@@ -215,7 +215,7 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);void gfs2_print_dbg (struct seq_file *seq,const char *fmt, ...);/** -* gfs2_glock_nq_init - intialize a holder and enqueue it on a glock +* gfs2_glock_nq_init - initialize a holder and enqueue it on a glock * @gl: the glock * @state: the state we're requesting * @flags: the modifier flags
Signature · 1 line
1.7.1.1