GFS2: Pre-pull patch posting (merge window)
cover GFS2: Pre-pull patch posting (merge window)
Hi,
Here is a list of patches we've accumulated for GFS2 for the current upstream merge window. We have a good mixture this time. Here are some of the features:
1. Fix a problem with RO mounts writing to the journal.
2. Further improvements to quotas on GFS2.
3. Added support for rename2 and RENAME_EXCHANGE on GFS2.
4. Increase performance by making glock lru_list less of a bottleneck.
5. Increase performance by avoiding unnecessary buffer_head releases.
6. Increase performance by using average glock round trip time from all CPUs.
7. Fixes for some compiler warnings and minor white space issues.
8. Other misc. bug fixes
Regards,
Bob Peterson
Red Hat File Systems
----------------------------------------------------------------
Abhi Das (5):
gfs2: handle NULL rgd in set_rgrp_preferences
gfs2: fix quota updates on block boundaries
gfs2: limit quota log messages
gfs2: s64 cast for negative quota value
gfs2: Don't support fallocate on jdata files
Antonio Ospite (1):
GFS2: inode.c: indent with TABs, not spaces
Benjamin Marzinski (3):
GFS2: mark the journal idle to fix ro mounts
GFS2: add support for rename2 and RENAME_EXCHANGE
GFS2: make sure S_NOSEC flag isn't overwritten
Bob Peterson (4):
GFS2: Use average srttb value in congestion calculations
GFS2: Average in only non-zero round-trip times for congestion stats
GFS2: Don't add all glocks to the lru
GFS2: Don't brelse rgrp buffer_heads every allocation
Fabian Frederick (3):
gfs2: convert simple_str to kstr
gfs2: kerneldoc warning fixes
gfs2: fix shadow warning in gfs2_rbm_find()
fs/gfs2/aops.c | 12 ++- fs/gfs2/file.c | 4 +- fs/gfs2/glock.c | 3 +- fs/gfs2/glops.c | 20 +++-- fs/gfs2/incore.h | 2 + fs/gfs2/inode.c | 211 +++++++++++++++++++++++++++++++++++++++++++++----- fs/gfs2/ops_fstype.c | 1 + fs/gfs2/quota.c | 212 +++++++++++++++++++++++++++++++-------------------- fs/gfs2/rgrp.c | 48 ++++++++---- fs/gfs2/rgrp.h | 1 + fs/gfs2/sys.c | 66 +++++++++++----- 11 files changed, 435 insertions(+), 145 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/16 GFS2: Use average srttb value in congestion calculations
This patch changes function gfs2_rgrp_congested so that it uses an average srttb (smoothed round trip time for blocking rgrp glocks) rather than the CPU-specific value. If we use the CPU-specific value it can incorrectly report no contention when there really is contention due to the glock processing occurring on a different CPU.
--- fs/gfs2/rgrp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/gfs2/rgrp.c +9 -4
@@ -1850,14 +1850,19 @@ static bool gfs2_rgrp_congested(const struct gfs2_rgrpd *rgd, int loops)const struct gfs2_sbd *sdp = gl->gl_sbd;struct gfs2_lkstats *st;s64 r_dcount, l_dcount; -s64 r_srttb, l_srttb; +s64 l_srttb, a_srttb =0 ;s64 srttb_diff;s64 sqr_diff;s64 var; +int cpu;preempt_disable (); +for_each_present_cpu (cpu) { + st = &per_cpu_ptr (sdp->sd_lkstats, cpu)->lkstats[LM_TYPE_RGRP ]; + a_srttb += st->stats[GFS2_LKS_SRTTB ]; + } st = &this_cpu_ptr (sdp->sd_lkstats)->lkstats[LM_TYPE_RGRP ]; - r_srttb = st->stats[GFS2_LKS_SRTTB ]; + a_srttb /=num_present_cpus (); r_dcount = st->stats[GFS2_LKS_DCOUNT ]; var = st->stats[GFS2_LKS_SRTTVARB ] + gl->gl_stats.stats[GFS2_LKS_SRTTVARB ];
@@ -1866,10 +1871,10 @@ static bool gfs2_rgrp_congested(const struct gfs2_rgrpd *rgd, int loops) l_srttb = gl->gl_stats.stats[GFS2_LKS_SRTTB ]; l_dcount = gl->gl_stats.stats[GFS2_LKS_DCOUNT ]; -if ((l_dcount <1 ) || (r_dcount <1 ) || (r_srttb ==0 )) +if ((l_dcount <1 ) || (r_dcount <1 ) || (a_srttb ==0 ))return false; - srttb_diff = r_srttb - l_srttb; + srttb_diff = a_srttb - l_srttb; sqr_diff = srttb_diff * srttb_diff; var *=2 ;
Signature · 1 line
2.1.0
PATCH 2/16 GFS2: Average in only non-zero round-trip times for congestion stats
In reply to Bob PetersonThis patch changes function gfs2_rgrp_congested so that it only factors in non-zero values into its average round trip time. If the round-trip time is zero for a particular cpu, that cpu has obviously never dealt with bouncing the resource group in question, so factoring in a zero value will only skew the numbers. It also fixes a compile error on some arches related to division.
--- fs/gfs2/rgrp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/gfs2/rgrp.c +7 -3
@@ -1854,15 +1854,19 @@ static bool gfs2_rgrp_congested(const struct gfs2_rgrpd *rgd, int loops)s64 srttb_diff;s64 sqr_diff;s64 var; -int cpu; +int cpu, nonzero =0 ;preempt_disable ();for_each_present_cpu (cpu) { st = &per_cpu_ptr (sdp->sd_lkstats, cpu)->lkstats[LM_TYPE_RGRP ]; - a_srttb += st->stats[GFS2_LKS_SRTTB ]; +if (st->stats[GFS2_LKS_SRTTB ]) { + a_srttb += st->stats[GFS2_LKS_SRTTB ]; + nonzero++; + } } st = &this_cpu_ptr (sdp->sd_lkstats)->lkstats[LM_TYPE_RGRP ]; - a_srttb /=num_present_cpus (); +if (nonzero) +do_div (a_srttb, nonzero); r_dcount = st->stats[GFS2_LKS_DCOUNT ]; var = st->stats[GFS2_LKS_SRTTVARB ] + gl->gl_stats.stats[GFS2_LKS_SRTTVARB ];
Signature · 1 line
2.1.0
PATCH 3/16 GFS2: mark the journal idle to fix ro mounts
In reply to Bob PetersonFrom: Benjamin Marzinski <[email protected]>
When gfs2 was mounted read-only and then unmounted, it was writing a header block to the journal in the syncing gfs2_log_flush() call from kill_sb(). This is because the journal was not being marked as idle until the first log header was written out, and on a read-only mount there never was a log header written out. Since the journal was not marked idle, gfs2_log_flush() was writing out a header lock to make sure it was empty during the sync. Not only did this cause IO to a read-only filesystem, but the journalling isn't completely initialized on read-only mounts, and so gfs2 was writing out the wrong sequence number in the log header.
Now, the journal is marked idle on mount, and gfs2_log_flush() won't write out anything until there starts being transactions to flush.
--- fs/gfs2/ops_fstype.c | 1 + 1 file changed, 1 insertion(+)
fs/gfs2/ops_fstype.c +1 -0
@@ -756,6 +756,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) } } + sdp->sd_log_idle =1 ;set_bit (SDF_JOURNAL_CHECKED , &sdp->sd_flags);gfs2_glock_dq_uninit (&ji_gh); jindex =0 ;
Signature · 1 line
2.1.0
PATCH 4/16 GFS2: inode.c: indent with TABs, not spaces
In reply to Bob PetersonFrom: Antonio Ospite <[email protected]>
Follow the same style used for the other functions in the same file.
--- fs/gfs2/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/inode.c +2 -2
@@ -1227,8 +1227,8 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,*/ static int gfs2_atomic_open (struct inode *dir,struct dentry *dentry, -struct file *file,unsigned flags, -umode_t mode,int *opened) +struct file *file,unsigned flags, +umode_t mode,int *opened) {struct dentry *d;bool excl = !!(flags &O_EXCL );
Signature · 1 line
2.1.0
PATCH 5/16 gfs2: handle NULL rgd in set_rgrp_preferences
In reply to Bob PetersonFrom: Abhi Das <[email protected]>
The function set_rgrp_preferences() does not handle the (rarely returned) NULL value from gfs2_rgrpd_get_next() and this patch fixes that.
The fs image in question is only 150MB in size which allows for only 1 rgrp to be created. The in-memory rb tree has only 1 node and when gfs2_rgrpd_get_next() is called on this sole rgrp, it returns NULL. (Default behavior is to wrap around the rb tree and return the first node to give the illusion of a circular linked list. In the case of only 1 rgrp, we can't have gfs2_rgrpd_get_next() return the same rgrp (first, last, next all point to the same rgrp)... that would cause unintended consequences and infinite loops.)
--- fs/gfs2/rgrp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/rgrp.c +2 -2
@@ -978,10 +978,10 @@ static void set_rgrp_preferences(struct gfs2_sbd *sdp) rgd->rd_flags |=GFS2_RDF_PREFERRED ;for (i =0 ; i < sdp->sd_journals; i++) { rgd =gfs2_rgrpd_get_next (rgd); -if (rgd == first) +if (!rgd || rgd == first)break ; } - }while (rgd != first); + }while (rgd && rgd != first); }/**
Signature · 1 line
2.1.0
PATCH 6/16 GFS2: add support for rename2 and RENAME_EXCHANGE
In reply to Bob PetersonFrom: Benjamin Marzinski <[email protected]>
gfs2 now uses the rename2 directory iop, and supports the RENAME_EXCHANGE flag (as well as RENAME_NOREPLACE, which the vfs takes care of).
--- fs/gfs2/inode.c | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 189 insertions(+), 16 deletions(-)
fs/gfs2/inode.c +189 -16
@@ -1307,6 +1307,35 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) }/** +* update_moved_ino - Update an inode that's being moved +* @ip: The inode being moved +* @ndip: The parent directory of the new filename +* @dir_rename: True of ip is a directory +* +* Returns: errno +*/ + +static int update_moved_ino (struct gfs2_inode *ip,struct gfs2_inode *ndip, +int dir_rename) +{ +int error; +struct buffer_head *dibh; + +if (dir_rename) +return gfs2_dir_mvino (ip, &gfs2_qdotdot, ndip,DT_DIR ); + + error =gfs2_meta_inode_buffer (ip, &dibh); +if (error) +return error; + ip->i_inode.i_ctime =CURRENT_TIME ; +gfs2_trans_add_meta (ip->i_gl, dibh); +gfs2_dinode_out (ip, dibh->b_data); +brelse (dibh); +return 0 ; +} + + +/** * gfs2_rename - Rename a file * @odir: Parent directory of old file name * @odentry: The old dentry of the file
@@ -1354,7 +1383,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,if (S_ISDIR (ip->i_inode.i_mode)) { dir_rename =1 ; -/* don't move a dirctory into it's subdir */ +/* don't move a directory into its subdir */ error =gfs2_ok_to_move (ip, ndip);if (error) goto out_gunlock_r;
@@ -1494,20 +1523,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,if (nip) error =gfs2_unlink_inode (ndip, ndentry); -if (dir_rename) { - error =gfs2_dir_mvino (ip, &gfs2_qdotdot, ndip,DT_DIR ); -if (error) - goto out_end_trans; - }else { -struct buffer_head *dibh; - error =gfs2_meta_inode_buffer (ip, &dibh); -if (error) - goto out_end_trans; - ip->i_inode.i_ctime =CURRENT_TIME ; -gfs2_trans_add_meta (ip->i_gl, dibh); -gfs2_dinode_out (ip, dibh->b_data); -brelse (dibh); - } + error =update_moved_ino (ip, ndip, dir_rename); +if (error) + goto out_end_trans; error =gfs2_dir_del (odip, odentry);if (error)
@@ -1539,6 +1557,161 @@ out: }/** +* gfs2_exchange - exchange two files +* @odir: Parent directory of old file name +* @odentry: The old dentry of the file +* @ndir: Parent directory of new file name +* @ndentry: The new dentry of the file +* @flags: The rename flags +* +* Returns: errno +*/ + +static int gfs2_exchange (struct inode *odir,struct dentry *odentry, +struct inode *ndir,struct dentry *ndentry, +unsigned int flags) +{ +struct gfs2_inode *odip =GFS2_I (odir); +struct gfs2_inode *ndip =GFS2_I (ndir); +struct gfs2_inode *oip =GFS2_I (odentry->d_inode); +struct gfs2_inode *nip =GFS2_I (ndentry->d_inode); +struct gfs2_sbd *sdp =GFS2_SB (odir); +struct gfs2_holder ghs[5 ], r_gh = { .gh_gl =NULL , }; +unsigned int num_gh; +unsigned int x; +umode_t old_mode = oip->i_inode.i_mode; +umode_t new_mode = nip->i_inode.i_mode; +int error; + + error =gfs2_rindex_update (sdp); +if (error) +return error; + +if (odip != ndip) { + error =gfs2_glock_nq_init (sdp->sd_rename_gl,LM_ST_EXCLUSIVE , +0 , &r_gh); +if (error) + goto out; + +if (S_ISDIR (old_mode)) { +/* don't move a directory into its subdir */ + error =gfs2_ok_to_move (oip, ndip); +if (error) + goto out_gunlock_r; + } + +if (S_ISDIR (new_mode)) { +/* don't move a directory into its subdir */ + error =gfs2_ok_to_move (nip, odip); +if (error) + goto out_gunlock_r; + } + } + + num_gh =1 ; +gfs2_holder_init (odip->i_gl,LM_ST_EXCLUSIVE ,0 , ghs); +if (odip != ndip) { +gfs2_holder_init (ndip->i_gl,LM_ST_EXCLUSIVE ,0 , ghs + num_gh); + num_gh++; + } +gfs2_holder_init (oip->i_gl,LM_ST_EXCLUSIVE ,0 , ghs + num_gh); + num_gh++; + +gfs2_holder_init (nip->i_gl,LM_ST_EXCLUSIVE ,0 , ghs + num_gh); + num_gh++; + +for (x =0 ; x < num_gh; x++) { + error =gfs2_glock_nq (ghs + x); +if (error) + goto out_gunlock; + } + + error = -ENOENT ; +if (oip->i_inode.i_nlink ==0 || nip->i_inode.i_nlink ==0 ) + goto out_gunlock; + + error =gfs2_unlink_ok (odip, &odentry->d_name, oip); +if (error) + goto out_gunlock; + error =gfs2_unlink_ok (ndip, &ndentry->d_name, nip); +if (error) + goto out_gunlock; + +if (S_ISDIR (old_mode)) { + error =gfs2_permission (odentry->d_inode,MAY_WRITE ); +if (error) + goto out_gunlock; + } +if (S_ISDIR (new_mode)) { + error =gfs2_permission (ndentry->d_inode,MAY_WRITE ); +if (error) + goto out_gunlock; + } + error =gfs2_trans_begin (sdp,4 *RES_DINODE +4 *RES_LEAF ,0 ); +if (error) + goto out_gunlock; + + error =update_moved_ino (oip, ndip,S_ISDIR (old_mode)); +if (error) + goto out_end_trans; + + error =update_moved_ino (nip, odip,S_ISDIR (new_mode)); +if (error) + goto out_end_trans; + + error =gfs2_dir_mvino (ndip, &ndentry->d_name, oip, +IF2DT (old_mode)); +if (error) + goto out_end_trans; + + error =gfs2_dir_mvino (odip, &odentry->d_name, nip, +IF2DT (new_mode)); +if (error) + goto out_end_trans; + +if (odip != ndip) { +if (S_ISDIR (new_mode) && !S_ISDIR (old_mode)) { +inc_nlink (&odip->i_inode); +drop_nlink (&ndip->i_inode); + }else if (S_ISDIR (old_mode) && !S_ISDIR (new_mode)) { +inc_nlink (&ndip->i_inode); +drop_nlink (&odip->i_inode); + } + } +mark_inode_dirty (&ndip->i_inode); +if (odip != ndip) +mark_inode_dirty (&odip->i_inode); + +out_end_trans: +gfs2_trans_end (sdp); +out_gunlock: +while (x--) { +gfs2_glock_dq (ghs + x); +gfs2_holder_uninit (ghs + x); + } +out_gunlock_r: +if (r_gh.gh_gl) +gfs2_glock_dq_uninit (&r_gh); +out: +return error; +} + +static int gfs2_rename2 (struct inode *odir,struct dentry *odentry, +struct inode *ndir,struct dentry *ndentry, +unsigned int flags) +{ + flags &= ~RENAME_NOREPLACE ; + +if (flags & ~RENAME_EXCHANGE ) +return -EINVAL ; + +if (flags &RENAME_EXCHANGE ) +return gfs2_exchange (odir, odentry, ndir, ndentry, flags); + +return gfs2_rename (odir, odentry, ndir, ndentry); +} + +/** * gfs2_follow_link - Follow a symbolic link * @dentry: The dentry of the link * @nd: Data that we pass to vfs_follow_link()
@@ -1943,7 +2116,7 @@ const struct inode_operations gfs2_dir_iops = { .mkdir = gfs2_mkdir, .rmdir = gfs2_unlink, .mknod = gfs2_mknod, - .rename = gfs2_rename, + .rename2 = gfs2_rename2, .permission = gfs2_permission, .setattr = gfs2_setattr, .getattr = gfs2_getattr,
Signature · 1 line
2.1.0
PATCH 7/16 GFS2: make sure S_NOSEC flag isn't overwritten
In reply to Bob PetersonFrom: Benjamin Marzinski <[email protected]>
At the end of gfs2_set_inode_flags inode->i_flags is set to flags, so we should be modifying flags instead of inode->i_flags, so it isn't overwritten.
--- fs/gfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/file.c +1 -1
@@ -180,7 +180,7 @@ void gfs2_set_inode_flags(struct inode *inode) flags &= ~(S_SYNC |S_APPEND |S_IMMUTABLE |S_NOATIME |S_DIRSYNC |S_NOSEC );if ((ip->i_eattr ==0 ) && !is_sxid (inode->i_mode)) - inode->i_flags |=S_NOSEC ; + flags |=S_NOSEC ;if (ip->i_diskflags &GFS2_DIF_IMMUTABLE ) flags |=S_IMMUTABLE ;if (ip->i_diskflags &GFS2_DIF_APPENDONLY )
Signature · 1 line
2.1.0
PATCH 8/16 gfs2: convert simple_str to kstr
In reply to Bob PetersonFrom: Fabian Frederick <[email protected]>
-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.
Thanks to Alexey Dobriyan for suggesting improvements in block_store() and wdack_store()
--- fs/gfs2/sys.c | 66 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 18 deletions(-)
fs/gfs2/sys.c +48 -18
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)static ssize_t freeze_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { -int error; -int n =simple_strtol (buf,NULL ,0 ); +int error, n; + + error =kstrtoint (buf,0 , &n); +if (error) +return error;if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)static ssize_t withdraw_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { +int error, val; +if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (simple_strtol (buf,NULL ,0 ) !=1 ) + error =kstrtoint (buf,0 , &val); +if (error) +return error; + +if (val !=1 )return -EINVAL ;gfs2_lm_withdraw (sdp,"withdrawing from cluster at user's request\n" );
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)static ssize_t statfs_sync_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { +int error, val; +if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (simple_strtol (buf,NULL ,0 ) !=1 ) + error =kstrtoint (buf,0 , &val); +if (error) +return error; + +if (val !=1 )return -EINVAL ;gfs2_statfs_sync (sdp->sd_vfs,0 );
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,static ssize_t quota_sync_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { +int error, val; +if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (simple_strtol (buf,NULL ,0 ) !=1 ) + error =kstrtoint (buf,0 , &val); +if (error) +return error; + +if (val !=1 )return -EINVAL ;gfs2_quota_sync (sdp->sd_vfs,0 );
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,if (!capable (CAP_SYS_ADMIN ))return -EPERM ; - id =simple_strtoul (buf,NULL ,0 ); + error =kstrtou32 (buf,0 , &id); +if (error) +return error; qid =make_kqid (current_user_ns (),USRQUOTA , id);if (!qid_valid (qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,if (!capable (CAP_SYS_ADMIN ))return -EPERM ; - id =simple_strtoul (buf,NULL ,0 ); + error =kstrtou32 (buf,0 , &id); +if (error) +return error; qid =make_kqid (current_user_ns (),GRPQUOTA , id);if (!qid_valid (qid))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)static ssize_t block_store (struct gfs2_sbd *sdp,const char *buf,size_t len) {struct lm_lockstruct *ls = &sdp->sd_lockstruct; -ssize_t ret = len; -int val; +int ret, val; - val =simple_strtol (buf,NULL ,0 ); + ret =kstrtoint (buf,0 , &val); +if (ret) +return ret;if (val ==1 )set_bit (DFL_BLOCK_LOCKS , &ls->ls_recover_flags);
@@ -336,9 +362,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)smp_mb__after_atomic ();gfs2_glock_thaw (sdp); }else { - ret = -EINVAL ; +return -EINVAL ; } -return ret; +return len; }static ssize_t wdack_show (struct gfs2_sbd *sdp,char *buf)
@@ -350,17 +376,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)static ssize_t wdack_store (struct gfs2_sbd *sdp,const char *buf,size_t len) { -ssize_t ret = len; -int val; +int ret, val; - val =simple_strtol (buf,NULL ,0 ); + ret =kstrtoint (buf,0 , &val); +if (ret) +return ret;if ((val ==1 ) && !strcmp (sdp->sd_lockstruct.ls_ops->lm_proto_name,"lock_dlm" ))complete (&sdp->sd_wdack);else - ret = -EINVAL ; -return ret; +return -EINVAL ; +return len; }static ssize_t lkfirst_show (struct gfs2_sbd *sdp,char *buf)
@@ -553,11 +580,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field, {struct gfs2_tune *gt = &sdp->sd_tune;unsigned int x; +int error;if (!capable (CAP_SYS_ADMIN ))return -EPERM ; - x =simple_strtoul (buf,NULL ,0 ); + error =kstrtouint (buf,0 , &x); +if (error) +return error;if (check_zero && !x)return -EINVAL ;
Signature · 1 line
2.1.0
PATCH 9/16 gfs2: kerneldoc warning fixes
In reply to Bob PetersonFrom: Fabian Frederick <[email protected]>
Fixes the following kernel-doc warnings:
Warning(fs/gfs2/aops.c:180): No description found for parameter 'wbc' Warning(fs/gfs2/aops.c:236): No description found for parameter 'end' Warning(fs/gfs2/aops.c:236): No description found for parameter 'done_index' Warning(fs/gfs2/aops.c:236): Excess function parameter 'writepage' description in 'gfs2_write_jdata_pagevec' Warning(fs/gfs2/aops.c:346): Excess function parameter 'writepage' description in 'gfs2_write_cache_jdata' Warning(fs/gfs2/aops.c:346): Excess function parameter 'data' description in 'gfs2_write_cache_jdata' Warning(fs/gfs2/aops.c:605): No description found for parameter 'file' Warning(fs/gfs2/aops.c:605): No description found for parameter 'mapping' Warning(fs/gfs2/aops.c:605): No description found for parameter 'pages' Warning(fs/gfs2/aops.c:605): No description found for parameter 'nr_pages' Warning(fs/gfs2/aops.c:870): No description found for parameter 'copied'
--- fs/gfs2/aops.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/gfs2/aops.c +8 -4
@@ -171,6 +171,7 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *w/** * gfs2_jdata_writepage - Write complete page * @page: Page to write +* @wbc: The writeback control * * Returns: errno *
@@ -221,9 +222,10 @@ static int gfs2_writepages(struct address_space *mapping,* gfs2_write_jdata_pagevec - Write back a pagevec's worth of pages * @mapping: The mapping * @wbc: The writeback control -* @writepage: The writepage function to call for each page * @pvec: The vector of pages * @nr_pages: The number of pages to write +* @end: End position +* @done_index: Page index * * Returns: non-zero if loop should terminate, zero otherwise */
@@ -333,8 +335,6 @@ continue_unlock:* gfs2_write_cache_jdata - Like write_cache_pages but different * @mapping: The mapping to write * @wbc: The writeback control -* @writepage: The writepage function to call -* @data: The data to pass to writepage * * The reason that we use our own function here is that we need to * start transactions before we grab page locks. This allows us
@@ -588,6 +588,10 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,/** * gfs2_readpages - Read a bunch of pages at once +* @file: The file to read from +* @mapping: Address space info +* @pages: List of pages to read +* @nr_pages: Number of pages to read * * Some notes: * 1. This is only for readahead, so we can simply ignore any things
@@ -853,7 +857,7 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,* @mapping: The address space to write to * @pos: The file position * @len: The length of the data -* @copied: +* @copied: How much was actually copied by the VFS * @page: The page that has been written * @fsdata: The fsdata (unused in GFS2) *
Signature · 1 line
2.1.0
PATCH 10/16 gfs2: fix shadow warning in gfs2_rbm_find()
In reply to Bob PetersonFrom: Fabian Frederick <[email protected]>
bi was already declared and initialized globally in gfs2_rbm_find()
--- fs/gfs2/rgrp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/gfs2/rgrp.c +1 -3
@@ -1711,10 +1711,8 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,return ret; bitmap_full:/* Mark bitmap as full and fall through */ -if ((state ==GFS2_BLKST_FREE ) && initial_offset ==0 ) { -struct gfs2_bitmap *bi =rbm_bi (rbm); +if ((state ==GFS2_BLKST_FREE ) && initial_offset ==0 )set_bit (GBF_FULL , &bi->bi_flags); - } next_bitmap:/* Find next bitmap in the rgrp */ rbm->offset =0 ;
Signature · 1 line
2.1.0
PATCH 11/16 gfs2: fix quota updates on block boundaries
In reply to Bob PetersonFrom: Abhi Das <[email protected]>
For smaller block sizes (512B, 1K, 2K), some quotas straddle block boundaries such that the usage value is on one block and the rest of the quota is on the previous block. In such cases, the value does not get updated correctly. This patch fixes that by addressing the boundary conditions correctly.
This patch also adds a (s64) cast that was missing in a call to gfs2_quota_change() in inode.c
--- fs/gfs2/inode.c | 2 +- fs/gfs2/quota.c | 197 +++++++++++++++++++++++++++++++++----------------------- 2 files changed, 119 insertions(+), 80 deletions(-)
fs/gfs2/inode.c +1 -1
@@ -1889,7 +1889,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)if (!uid_eq (ouid,NO_UID_QUOTA_CHANGE ) || !gid_eq (ogid,NO_GID_QUOTA_CHANGE )) { -gfs2_quota_change (ip, -ap.target, ouid, ogid); +gfs2_quota_change (ip, -(s64 )ap.target, ouid, ogid);gfs2_quota_change (ip, ap.target, nuid, ngid); }
fs/gfs2/quota.c +118 -79
226 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 12/16 gfs2: limit quota log messages
In reply to Bob PetersonFrom: Abhi Das <[email protected]>
This patch makes the quota subsystem only report once that a particular user/group has exceeded their allotted quota.
Previously, it was possible for a program to continuously try exceeding quota (despite receiving EDQUOT) and in turn trigger gfs2 to issue a kernel log message about quota exceed. In theory, this could get out of hand and flood the log and the filesystem hosting the log files.
--- fs/gfs2/incore.h | 1 + fs/gfs2/quota.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -432,6 +432,7 @@ enum {QDF_CHANGE =1 ,QDF_LOCKED =2 ,QDF_REFRESH =3 , + QDF_QMSG_QUIET = 4, }; struct gfs2_quota_data {
fs/gfs2/quota.c +11 -4
@@ -649,6 +649,8 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)slot_hold (qd); } +if (change <0 )/* Reset quiet flag if we freed some blocks */ +clear_bit (QDF_QMSG_QUIET , &qd->qd_flags);mutex_unlock (&sdp->sd_quota_mutex); }
@@ -1187,10 +1189,13 @@ int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,/* If no min_target specified or we don't meet * min_target, return -EDQUOT */ if (!ap->min_target || ap->min_target > ap->allowed) { -print_message (qd,"exceeded" ); -quota_send_warning (qd->qd_id, - sdp->sd_vfs->s_dev, -QUOTA_NL_BHARDWARN ); +if (!test_and_set_bit (QDF_QMSG_QUIET , + &qd->qd_flags)) { +print_message (qd,"exceeded" ); +quota_send_warning (qd->qd_id, + sdp->sd_vfs->s_dev, +QUOTA_NL_BHARDWARN ); + } error = -EDQUOT ;break ; }
@@ -1685,6 +1690,8 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,/* Apply changes */ error =gfs2_adjust_quota (ip, offset,0 , qd, fdq); +if (!error) +clear_bit (QDF_QMSG_QUIET , &qd->qd_flags);gfs2_trans_end (sdp); out_release:
Signature · 1 line
2.1.0
PATCH 13/16 gfs2: s64 cast for negative quota value
In reply to Bob PetersonFrom: Abhi Das <[email protected]>
One-line fix to cast quota value to s64 before comparison. By default the quantity is treated as u64.
--- fs/gfs2/quota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/quota.c +1 -1
@@ -798,7 +798,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, loc -=sizeof (q);/* gfs2_internal_read would've advanced the loc ptr */ err = -EIO ;be64_add_cpu (&q.qu_value, change); -if (be64_to_cpu (q.qu_value) <0 ) +if (((s64 )be64_to_cpu (q.qu_value)) <0 ) q.qu_value =0 ;/* Never go negative on quota usage */ qd->qd_qb.qb_value = q.qu_value;if (fdq) {
Signature · 1 line
2.1.0
PATCH 14/16 gfs2: Don't support fallocate on jdata files
In reply to Bob PetersonFrom: Abhi Das <[email protected]>
We cannot provide an efficient implementation due to the headers on the data blocks, so there doesn't seem much point in having it.
--- fs/gfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/file.c +1 -1
@@ -917,7 +917,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t lestruct gfs2_holder gh;int ret; -if (mode & ~FALLOC_FL_KEEP_SIZE ) +if ((mode & ~FALLOC_FL_KEEP_SIZE ) ||gfs2_is_jdata (ip))return -EOPNOTSUPP ;mutex_lock (&inode->i_mutex);
Signature · 1 line
2.1.0
PATCH 15/16 GFS2: Don't add all glocks to the lru
In reply to Bob PetersonThe glocks used for resource groups often come and go hundreds of thousands of times per second. Adding them to the lru list just adds unnecessary contention for the lru_lock spin_lock, especially considering we're almost certainly going to re-use the glock and take it back off the lru microseconds later. We never want the glock shrinker to cull them anyway. This patch adds a new bit in the glops that determines which glock types get put onto the lru list and which ones don't.
--- fs/gfs2/glock.c | 3 ++- fs/gfs2/glops.c | 6 ++++-- fs/gfs2/incore.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-)
fs/gfs2/glock.c +2 -1
@@ -1076,7 +1076,8 @@ void gfs2_glock_dq(struct gfs2_holder *gh) !test_bit(GLF_DEMOTE, &gl->gl_flags)) fast_path =1 ; } -if (!test_bit (GLF_LFLUSH , &gl->gl_flags) &&demote_ok (gl)) +if (!test_bit (GLF_LFLUSH , &gl->gl_flags) &&demote_ok (gl) && + (glops->go_flags &GLOF_LRU ))gfs2_glock_add_to_lru (gl);trace_gfs2_glock_queue (gh,0 );
fs/gfs2/glops.c +4 -2
@@ -561,7 +561,7 @@ const struct gfs2_glock_operations gfs2_inode_glops = { .go_lock = inode_go_lock, .go_dump = inode_go_dump, .go_type = LM_TYPE_INODE, - .go_flags = GLOF_ASPACE, + .go_flags = GLOF_ASPACE | GLOF_LRU, };const struct gfs2_glock_operations gfs2_rgrp_glops = {
@@ -584,10 +584,12 @@ const struct gfs2_glock_operations gfs2_freeze_glops = {const struct gfs2_glock_operations gfs2_iopen_glops = { .go_type =LM_TYPE_IOPEN , .go_callback = iopen_go_callback, + .go_flags =GLOF_LRU , };const struct gfs2_glock_operations gfs2_flock_glops = { .go_type =LM_TYPE_FLOCK , + .go_flags =GLOF_LRU , };const struct gfs2_glock_operations gfs2_nondisk_glops = {
@@ -596,7 +598,7 @@ const struct gfs2_glock_operations gfs2_nondisk_glops = {const struct gfs2_glock_operations gfs2_quota_glops = { .go_type =LM_TYPE_QUOTA , - .go_flags =GLOF_LVB , + .go_flags =GLOF_LVB |GLOF_LRU , };const struct gfs2_glock_operations gfs2_journal_glops = {
fs/gfs2/incore.h +1 -0
@@ -225,6 +225,7 @@ struct gfs2_glock_operations {const unsigned long go_flags;#define GLOF_ASPACE 1#define GLOF_LVB 2 +#define GLOF_LRU 4 };enum {
Signature · 1 line
2.1.0
PATCH 16/16 GFS2: Don't brelse rgrp buffer_heads every allocation
In reply to Bob PetersonThis patch allows the block allocation code to retain the buffers for the resource groups so they don't need to be re-read from buffer cache with every request. This is a performance improvement that's especially noticeable when resource groups are very large. For example, with 2GB resource groups and 4K blocks, there can be 33 blocks for every resource group. This patch allows those 33 buffers to be kept around and not read in and thrown away with every operation. The buffers are released when the resource group is either synced or invalidated.
--- fs/gfs2/glops.c | 14 +++++++++++--- fs/gfs2/rgrp.c | 23 +++++++++++++++++++---- fs/gfs2/rgrp.h | 1 + 3 files changed, 31 insertions(+), 7 deletions(-)
fs/gfs2/glops.c +11 -3
@@ -144,6 +144,12 @@ static void rgrp_go_sync(struct gfs2_glock *gl)struct gfs2_rgrpd *rgd;int error; +spin_lock (&gl->gl_spin); + rgd = gl->gl_object; +if (rgd) +gfs2_rgrp_brelse (rgd); +spin_unlock (&gl->gl_spin); +if (!test_and_clear_bit (GLF_DIRTY , &gl->gl_flags))return ;GLOCK_BUG_ON (gl, gl->gl_state !=LM_ST_EXCLUSIVE );
@@ -175,15 +181,17 @@ static void rgrp_go_inval(struct gfs2_glock *gl, int flags) {struct gfs2_sbd *sdp = gl->gl_sbd;struct address_space *mapping = &sdp->sd_aspace; +struct gfs2_rgrpd *rgd = gl->gl_object; + +if (rgd) +gfs2_rgrp_brelse (rgd);WARN_ON_ONCE (!(flags &DIO_METADATA ));gfs2_assert_withdraw (sdp, !atomic_read (&gl->gl_ail_count));truncate_inode_pages_range (mapping, gl->gl_vm.start, gl->gl_vm.end); -if (gl->gl_object) { -struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object; +if (rgd) rgd->rd_flags &= ~GFS2_RDF_UPTODATE ; - } }/**
fs/gfs2/rgrp.c +19 -4
@@ -1244,14 +1244,13 @@ int gfs2_rgrp_go_lock(struct gfs2_holder *gh) }/** -* gfs2_rgrp_go_unlock - Release RG bitmaps read in with gfs2_rgrp_bh_get() -* @gh: The glock holder for the resource group +* gfs2_rgrp_brelse - Release RG bitmaps read in with gfs2_rgrp_bh_get() +* @rgd: The resource group * */ -void gfs2_rgrp_go_unlock (struct gfs2_holder *gh) +void gfs2_rgrp_brelse (struct gfs2_rgrpd *rgd) { -struct gfs2_rgrpd *rgd = gh->gh_gl->gl_object;int x, length = rgd->rd_length;for (x =0 ; x < length; x++) {
@@ -1264,6 +1263,22 @@ void gfs2_rgrp_go_unlock(struct gfs2_holder *gh) } +/** +* gfs2_rgrp_go_unlock - Unlock a rgrp glock +* @gh: The glock holder for the resource group +* +*/ + +void gfs2_rgrp_go_unlock (struct gfs2_holder *gh) +{ +struct gfs2_rgrpd *rgd = gh->gh_gl->gl_object; +int demote_requested =test_bit (GLF_DEMOTE , &gh->gh_gl->gl_flags) | +test_bit (GLF_PENDING_DEMOTE , &gh->gh_gl->gl_flags); + +if (rgd && demote_requested) +gfs2_rgrp_brelse (rgd); +} +int gfs2_rgrp_send_discards (struct gfs2_sbd *sdp,u64 offset,struct buffer_head *bh,const struct gfs2_bitmap *bi,unsigned minlen,u64 *ptrimmed)
fs/gfs2/rgrp.h +1 -0
@@ -36,6 +36,7 @@ extern void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);extern int gfs2_rindex_update (struct gfs2_sbd *sdp);extern void gfs2_free_clones (struct gfs2_rgrpd *rgd);extern int gfs2_rgrp_go_lock (struct gfs2_holder *gh); +extern void gfs2_rgrp_brelse (struct gfs2_rgrpd *rgd);extern void gfs2_rgrp_go_unlock (struct gfs2_holder *gh);extern struct gfs2_alloc *gfs2_alloc_get (struct gfs2_inode *ip);
Signature · 1 line
2.1.0