GFS2: Pre-pull patch posting (merge window)
Subsystems (2)
Hi,
There are a few bug fixes for various, mostly very minor corner cases, plus some interesting new features. The new features include atomic_open whose main benefit will be the reduction in locking overhead in case of combined lookup/create and open operations, sorting the log buffer lists by block number to improve the efficiency of AIL writeback, and agressively issuing revokes in gfs2_log_flush to reduce overhead when dropping glocks,
Steve.
PATCH 1/12 GFS2: Sort buffer lists by inplace block number
From: Benjamin Marzinski <[email protected]>
This patch simply sort the data and metadata buffer lists by their inplace block number. This makes gfs2_log_flush issue the inplace IO in sequential order, which will hopefully speed up writing the IO out to disk.
fs/gfs2/lops.c +16 -0
@@ -16,6 +16,7 @@#include <linux/gfs2_ondisk.h> #include <linux/bio.h> #include <linux/fs.h> +#include <linux/list_sort.h> #include "gfs2.h" #include "incore.h"
@@ -401,6 +402,20 @@ static void gfs2_check_magic(struct buffer_head *bh)kunmap_atomic (kaddr); } +static int blocknr_cmp (void *priv,struct list_head *a,struct list_head *b) +{ +struct gfs2_bufdata *bda, *bdb; + + bda = list_entry(a, struct gfs2_bufdata, bd_list); + bdb = list_entry(b, struct gfs2_bufdata, bd_list); + +if (bda->bd_bh->b_blocknr < bdb->bd_bh->b_blocknr) +return -1 ; +if (bda->bd_bh->b_blocknr > bdb->bd_bh->b_blocknr) +return 1 ; +return 0 ; +} +static void gfs2_before_commit (struct gfs2_sbd *sdp,unsigned int limit,unsigned int total,struct list_head *blist,bool is_databuf)
@@ -413,6 +428,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,__be64 *ptr;gfs2_log_lock (sdp); +list_sort (NULL , blist, blocknr_cmp); bd1 = bd2 =list_prepare_entry (bd1, blist, bd_list);while (total) { num = total;
Signature · 1 line
1.7.4
PATCH 2/12 GFS2: Eliminate gfs2_rg_lops
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
With recent changes to the transactions, it appears that we are no longer using the "log ops" for resource groups. Since the log commit code processes the array of log ops, eliminating this should be marginally better for performance. Therefore this patch eliminates it.
fs/gfs2/lops.c +0 -5
@@ -852,10 +852,6 @@ const struct gfs2_log_operations gfs2_revoke_lops = { .lo_name = "revoke", }; -const struct gfs2_log_operations gfs2_rg_lops = { - .lo_name ="rg" , -}; -const struct gfs2_log_operations gfs2_databuf_lops = { .lo_before_commit = databuf_lo_before_commit, .lo_after_commit = databuf_lo_after_commit,
@@ -867,7 +863,6 @@ const struct gfs2_log_operations gfs2_databuf_lops = {const struct gfs2_log_operations *gfs2_log_ops[] = { &gfs2_databuf_lops, &gfs2_buf_lops, - &gfs2_rg_lops, &gfs2_revoke_lops,NULL , };
fs/gfs2/lops.h +0 -1
@@ -23,7 +23,6 @@extern const struct gfs2_log_operations gfs2_glock_lops;extern const struct gfs2_log_operations gfs2_buf_lops;extern const struct gfs2_log_operations gfs2_revoke_lops; -extern const struct gfs2_log_operations gfs2_rg_lops;extern const struct gfs2_log_operations gfs2_databuf_lops;extern const struct gfs2_log_operations *gfs2_log_ops[];
Signature · 1 line
1.7.4
PATCH 3/12 GFS2: Cocci spatch "ptr_ret.spatch"
In reply to Steven WhitehouseFrom: Thomas Meyer <[email protected]>
Use PTR_RET in place of open coding this function.
fs/gfs2/inode.c +1 -1
@@ -588,7 +588,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, inode =gfs2_lookupi (dir, &dentry->d_name,0 );gfs2_glock_dq_uninit (ghs);d_instantiate (dentry, inode); -return IS_ERR (inode) ?PTR_ERR (inode) :0 ; +return PTR_RET (inode); }if (error) goto fail_gunlock;
Signature · 1 line
1.7.4
PATCH 4/12 GFS2: Remove no-op wrapper function
In reply to Steven WhitehouseThis wrapper function is no longer required, so get rid of it.
fs/gfs2/quota.c +1 -6
@@ -1154,11 +1154,6 @@ int gfs2_quota_sync(struct super_block *sb, int type)return error; } -static int gfs2_quota_sync_timeo (struct super_block *sb,int type) -{ -return gfs2_quota_sync (sb, type); -} -int gfs2_quota_refresh (struct gfs2_sbd *sdp,struct kqid qid) {struct gfs2_quota_data *qd;
@@ -1414,7 +1409,7 @@ int gfs2_quotad(void *data) &tune->gt_statfs_quantum);/* Update quota file */ -quotad_check_timeo (sdp,"sync" , gfs2_quota_sync_timeo, t, +quotad_check_timeo (sdp,"sync" , gfs2_quota_sync, t, "ad_timeo, &tune->gt_quota_quantum);/* Check for & recover partially truncated inodes */
Signature · 1 line
1.7.4
PATCH 5/12 GFS2: fix error propagation in init_threads()
In reply to Steven WhitehouseFrom: Alexey Khoroshilov <[email protected]>
If kthread_run() fails, init_threads() returnsIS_ERR(p) instead of PTR_ERR(p).
Found by Linux Driver Verification project (linuxtesting.org).
fs/gfs2/ops_fstype.c +4 -4
@@ -916,16 +916,16 @@ static int init_threads(struct gfs2_sbd *sdp, int undo) goto fail_quotad; p =kthread_run (gfs2_logd, sdp,"gfs2_logd" ); - error =IS_ERR (p); -if (error) { +if (IS_ERR (p)) { + error =PTR_ERR (p);fs_err (sdp,"can't start logd thread: %d\n" , error);return error; } sdp->sd_logd_process = p; p =kthread_run (gfs2_quotad, sdp,"gfs2_quotad" ); - error =IS_ERR (p); -if (error) { +if (IS_ERR (p)) { + error =PTR_ERR (p);fs_err (sdp,"can't start quotad thread: %d\n" , error); goto fail; }
Signature · 1 line
1.7.4
PATCH 6/12 GFS2: Only do one directory search on create
In reply to Steven WhitehouseCreation of a new inode requires a directory search in order to ensure that we are not trying to create an inode with the same name as an existing one. This was hidden away inside the create_ok() function.
In the case that there was an existing inode, and a lookup can be substituted for a create (which is the case with regular files when the O_EXCL flag is not in use) then we were doing a second lookup in order to return the inode.
This patch merges these two lookups into one. This can be done by passing a flag to gfs2_dir_search() to tell it to just return -EEXIST in the cases where we don't actually want to look up the inode.
fs/gfs2/dir.c +13 -10
@@ -1555,9 +1555,9 @@ out:/** * gfs2_dir_search - Search a directory -* @dip: The GFS2 inode -* @filename: -* @inode: +* @dip: The GFS2 dir inode +* @name: The name we are looking up +* @fail_on_exist: Fail if the name exists rather than looking it up * * This routine searches a directory for a file or another directory. * Assumes a glock is held on dip.
@@ -1565,22 +1565,25 @@ out:* Returns: errno */ -struct inode *gfs2_dir_search (struct inode *dir,const struct qstr *name) +struct inode *gfs2_dir_search (struct inode *dir,const struct qstr *name, +bool fail_on_exist) {struct buffer_head *bh;struct gfs2_dirent *dent; -struct inode *inode; +u64 addr, formal_ino; +u16 dtype; dent =gfs2_dirent_search (dir, name, gfs2_dirent_find, &bh);if (dent) {if (IS_ERR (dent))return ERR_CAST (dent); - inode =gfs2_inode_lookup (dir->i_sb, -be16_to_cpu (dent->de_type), -be64_to_cpu (dent->de_inum.no_addr), -be64_to_cpu (dent->de_inum.no_formal_ino),0 ); + dtype =be16_to_cpu (dent->de_type); + addr =be64_to_cpu (dent->de_inum.no_addr); + formal_ino =be64_to_cpu (dent->de_inum.no_formal_ino);brelse (bh); -return inode; +if (fail_on_exist) +return ERR_PTR (-EEXIST ); +return gfs2_inode_lookup (dir->i_sb, dtype, addr, formal_ino,0 ); }return ERR_PTR (-ENOENT ); }
fs/gfs2/dir.h +2 -1
@@ -18,7 +18,8 @@ struct gfs2_inode;struct gfs2_inum ;extern struct inode *gfs2_dir_search (struct inode *dir, -const struct qstr *filename); +const struct qstr *filename, +bool fail_on_exist);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,
fs/gfs2/inode.c +10 -17
@@ -313,7 +313,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, goto out; } - inode =gfs2_dir_search (dir, name); + inode =gfs2_dir_search (dir, name, false);if (IS_ERR (inode)) error =PTR_ERR (inode); out:
@@ -346,17 +346,6 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,if (!dip->i_inode.i_nlink)return -ENOENT ; - error =gfs2_dir_check (&dip->i_inode, name,NULL ); -switch (error) { -case -ENOENT : - error =0 ; -break ; -case 0 : -return -EEXIST ; -default : -return error; - } -if (dip->i_entries == (u32)-1 )return -EFBIG ;if (S_ISDIR (mode) && dip->i_inode.i_nlink == (u32)-1 )
@@ -584,14 +573,18 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, goto fail; error =create_ok (dip, name, mode); -if ((error == -EEXIST ) &&S_ISREG (mode) && !excl) { - inode =gfs2_lookupi (dir, &dentry->d_name,0 ); +if (error) + goto fail_gunlock; + + inode =gfs2_dir_search (dir, &dentry->d_name, !S_ISREG (mode) || excl); + error =PTR_ERR (inode); +if (!IS_ERR (inode)) {gfs2_glock_dq_uninit (ghs);d_instantiate (dentry, inode); -return PTR_RET (inode); - } -if (error) +return 0 ; + }else if (error != -ENOENT ) { goto fail_gunlock; + } arq = error =gfs2_diradd_alloc_required (dir, name);if (error <0 )
Signature · 1 line
1.7.4
PATCH 7/12 GFS2: Add atomic_open support
In reply to Steven WhitehouseI've restricted atomic_open to only operate on regular files, although I still don't understand why atomic_open should not be possible also for directories on GFS2. That can always be added in later though, if it makes sense.
The ->atomic_open function can be passed negative dentries, which in most cases means either ENOENT (->lookup) or a call to d_instantiate (->create). In the GFS2 case though, we need to actually perform the look up, since we do not know whether there has been a new inode created on another node. The look up calls d_splice_alias which then tries to rehash the dentry - so the solution here is to simply check for that in d_splice_alias. The same issue is likely to affect any other cluster filesystem implementing ->atomic_open
fs/dcache.c +9 -2
@@ -1612,6 +1612,10 @@ EXPORT_SYMBOL(d_obtain_alias);* If a dentry was found and moved, then it is returned. Otherwise NULL * is returned. This matches the expected return value of ->lookup. * +* Cluster filesystems may call this function with a negative, hashed dentry. +* In that case, we know that the inode will be a regular file, and also this +* will only occur during atomic_open. So we need to check for the dentry +* being already hashed only in the final case. */ struct dentry *d_splice_alias (struct inode *inode,struct dentry *dentry) {
@@ -1636,8 +1640,11 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)security_d_instantiate (dentry, inode);d_rehash (dentry); } - }else -d_add (dentry, inode); + }else { +d_instantiate (dentry, inode); +if (d_unhashed (dentry)) +d_rehash (dentry); + }return new; }EXPORT_SYMBOL (d_splice_alias);
fs/gfs2/file.c +46 -23
96 lines not on this page · raw message
fs/gfs2/inode.c +99 -26
201 lines not on this page · raw message
fs/gfs2/inode.h +1 -0
@@ -109,6 +109,7 @@ extern int gfs2_permission(struct inode *inode, int mask);extern int gfs2_setattr_simple (struct inode *inode,struct iattr *attr);extern struct inode *gfs2_lookup_simple (struct inode *dip,const char *name);extern void gfs2_dinode_out (const struct gfs2_inode *ip,void *buf); +extern int gfs2_open_common (struct inode *inode,struct file *file);extern const struct inode_operations gfs2_file_iops;extern const struct inode_operations gfs2_dir_iops;
Signature · 1 line
1.7.4
PATCH 8/12 GFS2: fix regression in dir_double_exhash
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
Recent commit e8830d8 introduced a bug in function dir_double_exhash; it was failing to set h in the fall-back case. This patch corrects it.
fs/gfs2/dir.c +2 -1
@@ -1125,13 +1125,14 @@ static int dir_double_exhash(struct gfs2_inode *dip)if (IS_ERR (hc))return PTR_ERR (hc); - h = hc2 =kmalloc (hsize_bytes *2 ,GFP_NOFS | __GFP_NOWARN); + hc2 =kmalloc (hsize_bytes *2 ,GFP_NOFS | __GFP_NOWARN);if (hc2 ==NULL ) hc2 =__vmalloc (hsize_bytes *2 ,GFP_NOFS ,PAGE_KERNEL );if (!hc2)return -ENOMEM ; + h = hc2; error =gfs2_meta_inode_buffer (dip, &dibh);if (error) goto out_kfree;
Signature · 1 line
1.7.4
PATCH 9/12 GFS2: aggressively issue revokes in gfs2_log_flush
In reply to Steven WhitehouseFrom: Benjamin Marzinski <[email protected]>
This patch looks at all the outstanding blocks in all the transactions on the log, and moves the completed ones to the ail2 list. Then it issues revokes for these blocks. This will hopefully speed things up in situations where there is a lot of contention for glocks, especially if they are acquired serially.
revoke_lo_before_commit will issue at most one log block's full of these preemptive revokes. The amount of reserved log space that gfs2_log_reserve() ignores has been incremented to allow for this extra block.
This patch also consolidates the common revoke instructions into one function, gfs2_add_revoke().
fs/gfs2/glops.c +0 -8
@@ -54,7 +54,6 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)struct gfs2_bufdata *bd, *tmp;struct buffer_head *bh;const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock); -sector_t blocknr;gfs2_log_lock (sdp);spin_lock (&sdp->sd_ail_lock);
@@ -65,13 +64,6 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)continue ;gfs2_ail_error (gl, bh); } - blocknr = bh->b_blocknr; - bh->b_private =NULL ; -gfs2_remove_from_ail (bd);/* drops ref on bh */ - - bd->bd_bh =NULL ; - bd->bd_blkno = blocknr; -gfs2_trans_add_revoke (sdp, bd); }GLOCK_BUG_ON (gl, !fsync &&atomic_read (&gl->gl_ail_count));
fs/gfs2/log.c +74 -4
109 lines not on this page · raw message
fs/gfs2/log.h +2 -0
@@ -72,5 +72,7 @@ extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)extern void gfs2_log_shutdown (struct gfs2_sbd *sdp);extern void gfs2_meta_syncfs (struct gfs2_sbd *sdp);extern int gfs2_logd (void *data); +extern void gfs2_add_revoke (struct gfs2_sbd *sdp,struct gfs2_bufdata *bd); +extern void gfs2_write_revokes (struct gfs2_sbd *sdp);#endif /* __LOG_DOT_H__ */
fs/gfs2/lops.c +1 -0
@@ -606,6 +606,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)struct page *page;unsigned int length; +gfs2_write_revokes (sdp);if (!sdp->sd_log_num_revoke)return ;
fs/gfs2/meta_io.c +0 -4
@@ -296,10 +296,6 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, intif (bd) {spin_lock (&sdp->sd_ail_lock);if (bd->bd_tr) { -gfs2_remove_from_ail (bd); - bh->b_private =NULL ; - bd->bd_bh =NULL ; - bd->bd_blkno = bh->b_blocknr;gfs2_trans_add_revoke (sdp, bd); }spin_unlock (&sdp->sd_ail_lock);
fs/gfs2/trans.c +1 -7
@@ -274,15 +274,9 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)struct gfs2_trans *tr = current->journal_info;BUG_ON (!list_empty (&bd->bd_list)); -BUG_ON (!list_empty (&bd->bd_ail_st_list)); -BUG_ON (!list_empty (&bd->bd_ail_gl_list)); - bd->bd_ops = &gfs2_revoke_lops; +gfs2_add_revoke (sdp, bd); tr->tr_touched =1 ; tr->tr_num_revoke++; - sdp->sd_log_num_revoke++; -atomic_inc (&gl->gl_revokes); -set_bit (GLF_LFLUSH , &gl->gl_flags); -list_add (&bd->bd_list, &sdp->sd_log_le_revoke); }void gfs2_trans_add_unrevoke (struct gfs2_sbd *sdp,u64 blkno,unsigned int len)
Signature · 1 line
1.7.4
PATCH 10/12 GFS2: fix warning message
In reply to Steven WhitehouseFrom: Benjamin Marzinski <[email protected]>
This patch fixes a warning message introduced in the recent "GFS2: aggressively issue revokes in gfs2_log_flush" patch.
fs/gfs2/trans.c +0 -1
@@ -270,7 +270,6 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)void gfs2_trans_add_revoke (struct gfs2_sbd *sdp,struct gfs2_bufdata *bd) { -struct gfs2_glock *gl = bd->bd_gl;struct gfs2_trans *tr = current->journal_info;BUG_ON (!list_empty (&bd->bd_list));
Signature · 1 line
1.7.4
PATCH 11/12 GFS2: Fix fstrim boundary conditions
In reply to Steven WhitehouseFrom: Abhijith Das <[email protected]>
This patch correctly distinguishes two boundary conditions:
1. When the given range is entire within the unaccounted space between two rgrps, and
2. The range begins beyond the end of the filesystem
Also fix the unit of the returned value r.len (total trimming) to be in bytes instead of the (incorrect) 512 byte blocks
With this patch, GFS2 passes multiple iterations of all the relevant xfstests (251, 260, 288) with different fs block sizes.
fs/gfs2/rgrp.c +8 -6
@@ -1288,13 +1288,15 @@ int gfs2_fitrim(struct file *filp, void __user *argp) minlen =max_t (u64, r.minlen, q->limits.discard_granularity) >> bs_shift; +if (end <= start || minlen > sdp->sd_max_rg_data) +return -EINVAL ; + rgd =gfs2_blk2rgrpd (sdp, start,0 ); - rgd_end =gfs2_blk2rgrpd (sdp, end -1 ,0 ); + rgd_end =gfs2_blk2rgrpd (sdp, end,0 ); -if (end <= start || - minlen > sdp->sd_max_rg_data || - start > rgd_end->rd_data0 + rgd_end->rd_data) -return -EINVAL ; +if ((gfs2_rgrpd_get_first (sdp) ==gfs2_rgrpd_get_next (rgd_end)) + && (start > rgd_end->rd_data0 + rgd_end->rd_data)) +return -EINVAL ;/* start is beyond the end of the fs */ while (1 ) {
@@ -1336,7 +1338,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp) } out: - r.len = trimmed <<9 ; + r.len = trimmed << bs_shift;if (copy_to_user (argp, &r,sizeof (r)))return -EFAULT ;
Signature · 1 line
1.7.4
PATCH 12/12 GFS2: Reserve journal space for quota change in do_grow
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
If a GFS2 file system is mounted with quotas and a file is grown in such a way that its free blocks for the allocation are represented in a secondary bitmap, GFS2 ran out of blocks in the transaction. That resulted in "fatal: assertion "tr->tr_num_buf <= tr->tr_blocks". This patch reserves extra blocks for the quota change so the transaction has enough space.
fs/gfs2/bmap.c +3 -1
@@ -1232,7 +1232,9 @@ static int do_grow(struct inode *inode, u64 size) unstuff =1 ; } - error =gfs2_trans_begin (sdp,RES_DINODE +RES_STATFS +RES_RG_BIT ,0 ); + error =gfs2_trans_begin (sdp,RES_DINODE +RES_STATFS +RES_RG_BIT + + (sdp->sd_args.ar_quota ==GFS2_QUOTA_OFF ? +0 :RES_QUOTA ),0 );if (error) goto do_grow_release;
Signature · 1 line
1.7.4