Pre-pull patch posting
Hi,
So as the merge window draws closer, here is the current content of the GFS2 git tree. The major item this time is patch 5 in the series. This contians by far the majority of the changes, and the majority of those changes are actually removal of code. The patch merges the lock_dlm module (not the dlm itself, but GFS2's interface to the dlm) into GFS2 itself. This means that a number of optimisations are then possible in terms of merging strucutures resulting in a considerable saving in memory.
Since that patch is so large (I'm afraid that it really doesn't make any sense to split it up) its been in the -nmw git tree for the whole period since the last merge window and has also been posted for review on cluster-devel on a number of occasions before that. We've run a number of tests on it as well in that period, so I believe that its pretty stable now. It certainly makes the code a lot cleaner and easier to follow in that area.
The remainder of the patches are mostly bug fixes, but there are one or two other interesting features, those being:
o GFS2 now supports the discard I/O requests for thin provisioning, etc
o A new "demote a glock" interface is added to sysfs to help in testing GFS2
o With a new mkfs.gfs2 which writes UUIDs, the UUID is now included in uevent messages (with older filesystems which don't have UUIDs, we just don't send that information)
The GFS2 tracing patches which I posted a little while back are not included in this patch set. I think I can see what I need to do in order to avoid patching blktrace now, so my plan is to look at those patches again after this merge window, and when all the queued patches for the tracing subsystem have been merged.
As always, please let us know if you spot any issues in the patches,
Steve.
PATCH 1/18 GFS2: Fix remount argument parsing
From: Steven Whitehouse <[email protected]>
The following patch fixes an issue relating to remount and argument parsing. After this fix is applied, remount becomes atomic in that it either succeeds changing the mount to the new state, or it fails and leaves it in the old state. Previously it was possible for the parsing of options to fail part way though and for the fs to be left in a state where some of the new arguments had been applied, but some had not.
fs/gfs2/mount.c +19 -92
@@ -17,7 +17,7 @@#include "gfs2.h" #include "incore.h" -#include "mount.h" +#include "super.h" #include "sys.h" #include "util.h"
@@ -77,101 +77,46 @@ static const match_table_t tokens = {* Return: errno */ -int gfs2_mount_args (struct gfs2_sbd *sdp,char *data_arg,int remount) +int gfs2_mount_args (struct gfs2_sbd *sdp,struct gfs2_args *args,char *options) { -struct gfs2_args *args = &sdp->sd_args; -char *data = data_arg; -char *options, *o, *v; -int error =0 ; - -if (!remount) { -/* Set some defaults */ - args->ar_quota =GFS2_QUOTA_DEFAULT ; - args->ar_data =GFS2_DATA_DEFAULT ; - } +char *o; +int token; +substring_t tmp[MAX_OPT_ARGS ];/* Split the options into tokens with the "," character and process them */ -for (options = data; (o =strsep (&options,"," )); ) { -int token; -substring_t tmp[MAX_OPT_ARGS ]; - -if (!*o) +while (1 ) { + o =strsep (&options,"," ); +if (o ==NULL ) +break ; +if (*o =='\0' )continue ; token =match_token (o, tokens, tmp);switch (token) {case Opt_lockproto: - v =match_strdup (&tmp[0 ]); -if (!v) { -fs_info (sdp,"no memory for lockproto\n" ); - error = -ENOMEM ; - goto out_error; - } - -if (remount &&strcmp (v, args->ar_lockproto)) { -kfree (v); - goto cant_remount; - } - -strncpy (args->ar_lockproto, v,GFS2_LOCKNAME_LEN ); - args->ar_lockproto[GFS2_LOCKNAME_LEN -1 ] =0 ; -kfree (v); +match_strlcpy (args->ar_lockproto, &tmp[0 ], +GFS2_LOCKNAME_LEN );break ;case Opt_locktable: - v =match_strdup (&tmp[0 ]); -if (!v) { -fs_info (sdp,"no memory for locktable\n" ); - error = -ENOMEM ; - goto out_error; - } - -if (remount &&strcmp (v, args->ar_locktable)) { -kfree (v); - goto cant_remount; - } - -strncpy (args->ar_locktable, v,GFS2_LOCKNAME_LEN ); - args->ar_locktable[GFS2_LOCKNAME_LEN -1 ] =0 ; -kfree (v); +match_strlcpy (args->ar_locktable, &tmp[0 ], +GFS2_LOCKNAME_LEN );break ;case Opt_hostdata: - v =match_strdup (&tmp[0 ]); -if (!v) { -fs_info (sdp,"no memory for hostdata\n" ); - error = -ENOMEM ; - goto out_error; - } - -if (remount &&strcmp (v, args->ar_hostdata)) { -kfree (v); - goto cant_remount; - } - -strncpy (args->ar_hostdata, v,GFS2_LOCKNAME_LEN ); - args->ar_hostdata[GFS2_LOCKNAME_LEN -1 ] =0 ; -kfree (v); +match_strlcpy (args->ar_hostdata, &tmp[0 ], +GFS2_LOCKNAME_LEN );break ;case Opt_spectator: -if (remount && !args->ar_spectator) - goto cant_remount; args->ar_spectator =1 ; - sdp->sd_vfs->s_flags |=MS_RDONLY ;break ;case Opt_ignore_local_fs: -if (remount && !args->ar_ignore_local_fs) - goto cant_remount; args->ar_ignore_local_fs =1 ;break ;case Opt_localflocks: -if (remount && !args->ar_localflocks) - goto cant_remount; args->ar_localflocks =1 ;break ;case Opt_localcaching: -if (remount && !args->ar_localcaching) - goto cant_remount; args->ar_localcaching =1 ;break ;case Opt_debug:
@@ -181,17 +126,13 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount) args->ar_debug =0 ;break ;case Opt_upgrade: -if (remount && !args->ar_upgrade) - goto cant_remount; args->ar_upgrade =1 ;break ;case Opt_acl: args->ar_posix_acl =1 ; - sdp->sd_vfs->s_flags |=MS_POSIXACL ;break ;case Opt_noacl: args->ar_posix_acl =0 ; - sdp->sd_vfs->s_flags &= ~MS_POSIXACL ;break ;case Opt_quota_off: args->ar_quota =GFS2_QUOTA_OFF ;
@@ -215,29 +156,15 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount) args->ar_data =GFS2_DATA_ORDERED ;break ;case Opt_meta: -if (remount && args->ar_meta !=1 ) - goto cant_remount; args->ar_meta =1 ;break ;case Opt_err:default : -fs_info (sdp,"unknown option: %s\n" , o); - error = -EINVAL ; - goto out_error; +fs_info (sdp,"invalid mount option: %s\n" , o); +return -EINVAL ; } } -out_error: -if (error) -fs_info (sdp,"invalid mount option(s)\n" ); - -if (data != data_arg) -kfree (data); - -return error; - -cant_remount: -fs_info (sdp,"can't remount with option %s\n" , o); -return -EINVAL ; +return 0 ; }
fs/gfs2/mount.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* -* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. -* -* This copyrighted material is made available to anyone wishing to use, -* modify, copy, or redistribute it subject to the terms and conditions -* of the GNU General Public License version 2. -*/ - -#ifndef __MOUNT_DOT_H__ -#define __MOUNT_DOT_H__ - -struct gfs2_sbd ; - -int gfs2_mount_args (struct gfs2_sbd *sdp,char *data_arg,int remount); - -#endif /* __MOUNT_DOT_H__ */
fs/gfs2/ops_fstype.c +9 -2
@@ -25,7 +25,6 @@#include "glock.h" #include "glops.h" #include "inode.h" -#include "mount.h" #include "recovery.h" #include "rgrp.h" #include "super.h"
@@ -1116,12 +1115,20 @@ static int fill_super(struct super_block *sb, void *data, int silent)return -ENOMEM ; } - error =gfs2_mount_args (sdp, (char *)data,0 ); + sdp->sd_args.ar_quota =GFS2_QUOTA_DEFAULT ; + sdp->sd_args.ar_data =GFS2_DATA_DEFAULT ; + + error =gfs2_mount_args (sdp, &sdp->sd_args, data);if (error) {printk (KERN_WARNING "GFS2: can't parse mount arguments\n" ); goto fail; } +if (sdp->sd_args.ar_spectator) + sb->s_flags |=MS_RDONLY ; +if (sdp->sd_args.ar_posix_acl) + sb->s_flags |=MS_POSIXACL ; + sb->s_magic =GFS2_MAGIC ; sb->s_op = &gfs2_super_ops; sb->s_export_op = &gfs2_export_ops;
fs/gfs2/ops_super.c +31 -10
69 lines not on this page · raw message
fs/gfs2/super.h +14 -12
@@ -14,7 +14,7 @@#include <linux/dcache.h> #include "incore.h" -void gfs2_lm_unmount (struct gfs2_sbd *sdp); +extern void gfs2_lm_unmount (struct gfs2_sbd *sdp);static inline unsigned int gfs2_jindex_size (struct gfs2_sbd *sdp) {
@@ -27,21 +27,23 @@ static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp)void gfs2_jindex_free (struct gfs2_sbd *sdp); -struct gfs2_jdesc *gfs2_jdesc_find (struct gfs2_sbd *sdp,unsigned int jid); -int gfs2_jdesc_check (struct gfs2_jdesc *jd); +extern int gfs2_mount_args (struct gfs2_sbd *sdp,struct gfs2_args *args,char *data); -int gfs2_lookup_in_master_dir (struct gfs2_sbd *sdp,char *filename, -struct gfs2_inode **ipp); +extern struct gfs2_jdesc *gfs2_jdesc_find (struct gfs2_sbd *sdp,unsigned int jid); +extern int gfs2_jdesc_check (struct gfs2_jdesc *jd); -int gfs2_make_fs_rw (struct gfs2_sbd *sdp); +extern int gfs2_lookup_in_master_dir (struct gfs2_sbd *sdp,char *filename, +struct gfs2_inode **ipp); -int gfs2_statfs_init (struct gfs2_sbd *sdp); -void gfs2_statfs_change (struct gfs2_sbd *sdp, -s64 total,s64 free,s64 dinodes); -int gfs2_statfs_sync (struct gfs2_sbd *sdp); +extern int gfs2_make_fs_rw (struct gfs2_sbd *sdp); -int gfs2_freeze_fs (struct gfs2_sbd *sdp); -void gfs2_unfreeze_fs (struct gfs2_sbd *sdp); +extern int gfs2_statfs_init (struct gfs2_sbd *sdp); +extern void gfs2_statfs_change (struct gfs2_sbd *sdp,s64 total,s64 free, +s64 dinodes); +extern int gfs2_statfs_sync (struct gfs2_sbd *sdp); + +extern int gfs2_freeze_fs (struct gfs2_sbd *sdp); +extern void gfs2_unfreeze_fs (struct gfs2_sbd *sdp);extern struct file_system_type gfs2_fs_type;extern struct file_system_type gfs2meta_fs_type;
Signature · 1 line
1.6.0.3
PATCH 2/18 GFS2: Bring back lvb-related stuff to lock_nolock to support quotas
From: Abhijith Das <[email protected]>
The quota code uses lvbs and this is currently not implemented in lock_nolock, thereby causing panics when quota is enabled with lock_nolock. This patch adds the relevant bits.
fs/gfs2/locking.c +82 -0
@@ -23,11 +23,74 @@ struct lmh_wrapper {const struct lm_lockops *lw_ops; }; +struct nolock_lockspace { +unsigned int nl_lvb_size; +}; + +/** +* nolock_get_lock - get a lm_lock_t given a descripton of the lock +* @lockspace: the lockspace the lock lives in +* @name: the name of the lock +* @lockp: return the lm_lock_t here +* +* Returns: 0 on success, -EXXX on failure +*/ + +static int nolock_get_lock (void *lockspace,struct lm_lockname *name, +void **lockp) +{ + *lockp = lockspace; +return 0 ; +} + +/** +* nolock_put_lock - get rid of a lock structure +* @lock: the lock to throw away +* +*/ + +static void nolock_put_lock (void *lock) +{ +} + +/** +* nolock_hold_lvb - hold on to a lock value block +* @lock: the lock the LVB is associated with +* @lvbp: return the lm_lvb_t here +* +* Returns: 0 on success, -EXXX on failure +*/ + +static int nolock_hold_lvb (void *lock,char **lvbp) +{ +struct nolock_lockspace *nl = lock; +int error =0 ; + + *lvbp =kzalloc (nl->nl_lvb_size,GFP_KERNEL ); +if (!*lvbp) + error = -ENOMEM ; + +return error; +} + +/** +* nolock_unhold_lvb - release a LVB +* @lock: the lock the LVB is associated with +* @lvb: the lock value block +* +*/ + +static void nolock_unhold_lvb (void *lock,char *lvb) +{ +kfree (lvb); +} +static int nolock_mount (char *table_name,char *host_data,lm_callback_t cb,void *cb_data,unsigned int min_lvb_size,int flags,struct lm_lockstruct *lockstruct,struct kobject *fskobj); +static void nolock_unmount (void *lockspace);/* List of registered low-level locking protocols. A file system selects one of them by name at mount time, e.g. lock_nolock, lock_dlm. */
@@ -35,6 +98,11 @@ static int nolock_mount(char *table_name, char *host_data,static const struct lm_lockops nolock_ops = { .lm_proto_name ="lock_nolock" , .lm_mount = nolock_mount, + .lm_unmount = nolock_unmount, + .lm_get_lock = nolock_get_lock, + .lm_put_lock = nolock_put_lock, + .lm_hold_lvb = nolock_hold_lvb, + .lm_unhold_lvb = nolock_unhold_lvb, };static struct lmh_wrapper nolock_proto = {
@@ -53,6 +121,7 @@ static int nolock_mount(char *table_name, char *host_data, {char *c;unsigned int jid; +struct nolock_lockspace *nl; c =strstr (host_data,"jid=" );if (!c)
@@ -62,15 +131,28 @@ static int nolock_mount(char *table_name, char *host_data,sscanf (c,"%u" , &jid); } + nl =kzalloc (sizeof (struct nolock_lockspace ),GFP_KERNEL ); +if (!nl) +return -ENOMEM ; + + nl->nl_lvb_size = min_lvb_size; + lockstruct->ls_jid = jid; lockstruct->ls_first =1 ; lockstruct->ls_lvb_size = min_lvb_size; + lockstruct->ls_lockspace = nl; lockstruct->ls_ops = &nolock_ops; lockstruct->ls_flags =LM_LSFLAG_LOCAL ;return 0 ; } +static void nolock_unmount (void *lockspace) +{ +struct nolock_lockspace *nl = lockspace; +kfree (nl); +} +/** * gfs2_register_lockproto - Register a low-level locking protocol * @proto: the protocol definition
Signature · 1 line
1.6.0.3
PATCH 3/18 GFS2: change gfs2_quota_scan into a shrinker
From: Abhijith Das <[email protected]>
Deallocation of gfs2_quota_data objects now happens on-demand through a shrinker instead of routinely deallocating through the quotad daemon.
fs/gfs2/incore.h +3 -3
@@ -283,7 +283,9 @@ enum {struct gfs2_quota_data {struct list_head qd_list; -unsigned int qd_count; +struct list_head qd_reclaim; + +atomic_t qd_count;u32 qd_id;unsigned long qd_flags;/* QDF_... */
@@ -303,7 +305,6 @@ struct gfs2_quota_data {u64 qd_sync_gen;unsigned long qd_last_warn; -unsigned long qd_last_touched; };struct gfs2_trans {
@@ -406,7 +407,6 @@ struct gfs2_tune {unsigned int gt_quota_warn_period;/* Secs between quota warn msgs */ unsigned int gt_quota_scale_num;/* Numerator */ unsigned int gt_quota_scale_den;/* Denominator */ -unsigned int gt_quota_cache_secs;unsigned int gt_quota_quantum;/* Secs between syncs to quota file */ unsigned int gt_new_files_jdata;unsigned int gt_max_readahead;/* Max bytes to read-ahead from disk */
fs/gfs2/main.c +10 -0
@@ -23,6 +23,12 @@#include "sys.h" #include "util.h" #include "glock.h" +#include "quota.h" + +static struct shrinker qd_shrinker = { + .shrink = gfs2_shrink_qd_memory, + .seeks =DEFAULT_SEEKS , +};static void gfs2_init_inode_once (void *foo) {
@@ -100,6 +106,8 @@ static int __init init_gfs2_fs(void)if (!gfs2_quotad_cachep) goto fail; +register_shrinker (&qd_shrinker); + error =register_filesystem (&gfs2_fs_type);if (error) goto fail;
@@ -117,6 +125,7 @@ static int __init init_gfs2_fs(void) fail_unregister:unregister_filesystem (&gfs2_fs_type); fail: +unregister_shrinker (&qd_shrinker);gfs2_glock_exit ();if (gfs2_quotad_cachep)
@@ -145,6 +154,7 @@ fail: static void __exit exit_gfs2_fs(void) { +unregister_shrinker (&qd_shrinker);gfs2_glock_exit ();gfs2_unregister_debugfs ();unregister_filesystem (&gfs2_fs_type);
fs/gfs2/ops_address.c +1 -0
@@ -442,6 +442,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)*/ if (unlikely (page->index)) {zero_user (page,0 ,PAGE_CACHE_SIZE ); +SetPageUptodate (page);return 0 ; }
fs/gfs2/ops_fstype.c +0 -1
@@ -63,7 +63,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt) gt->gt_quota_warn_period =10 ; gt->gt_quota_scale_num =1 ; gt->gt_quota_scale_den =1 ; - gt->gt_quota_cache_secs =300 ; gt->gt_quota_quantum =60 ; gt->gt_new_files_jdata =0 ; gt->gt_max_readahead =1 <<18 ;
fs/gfs2/quota.c +98 -67
305 lines not on this page · raw message
fs/gfs2/quota.h +2 -0
@@ -49,4 +49,6 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip) return ret; } +extern int gfs2_shrink_qd_memory (int nr,gfp_t gfp_mask); +#endif /* __QUOTA_DOT_H__ */
fs/gfs2/sys.c +0 -2
@@ -373,7 +373,6 @@ TUNE_ATTR(complain_secs, 0);TUNE_ATTR (statfs_slow,0 );TUNE_ATTR (new_files_jdata,0 );TUNE_ATTR (quota_simul_sync,1 ); -TUNE_ATTR (quota_cache_secs,1 );TUNE_ATTR (stall_secs,1 );TUNE_ATTR (statfs_quantum,1 );TUNE_ATTR_DAEMON (recoverd_secs, recoverd_process);
@@ -389,7 +388,6 @@ static struct attribute *tune_attrs[] = { &tune_attr_complain_secs.attr, &tune_attr_statfs_slow.attr, &tune_attr_quota_simul_sync.attr, - &tune_attr_quota_cache_secs.attr, &tune_attr_stall_secs.attr, &tune_attr_statfs_quantum.attr, &tune_attr_recoverd_secs.attr,
Signature · 1 line
1.6.0.3
PATCH 4/18 GFS2: Remove "double" locking in quota
From: Steven Whitehouse <[email protected]>
We only really need a single spin lock for the quota data, so lets just use the lru lock for now.
fs/gfs2/incore.h +0 -1
@@ -540,7 +540,6 @@ struct gfs2_sbd {struct list_head sd_quota_list;atomic_t sd_quota_count; -spinlock_t sd_quota_spin;struct mutex sd_quota_mutex;wait_queue_head_t sd_quota_wait;struct list_head sd_trunc_list;
fs/gfs2/ops_fstype.c +0 -1
@@ -98,7 +98,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)mutex_init (&sdp->sd_jindex_mutex);INIT_LIST_HEAD (&sdp->sd_quota_list); -spin_lock_init (&sdp->sd_quota_spin);mutex_init (&sdp->sd_quota_mutex);init_waitqueue_head (&sdp->sd_quota_wait);INIT_LIST_HEAD (&sdp->sd_trunc_list);
fs/gfs2/quota.c +14 -26
@@ -104,13 +104,11 @@ int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask)/* Free from the filesystem-specific list */ list_del (&qd->qd_list); -spin_lock (&sdp->sd_quota_spin);gfs2_assert_warn (sdp, !qd->qd_change);gfs2_assert_warn (sdp, !qd->qd_slot_count);gfs2_assert_warn (sdp, !qd->qd_bh_count);gfs2_lvb_unhold (qd->qd_gl); -spin_unlock (&sdp->sd_quota_spin);atomic_dec (&sdp->sd_quota_count);/* Delete it from the common reclaim list */
@@ -249,10 +247,10 @@ static int slot_get(struct gfs2_quota_data *qd)unsigned int c, o =0 , b;unsigned char byte =0 ; -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock);if (qd->qd_slot_count++) { -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);return 0 ; }
@@ -276,13 +274,13 @@ found: sdp->sd_quota_bitmap[c][o] |=1 << b; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);return 0 ; fail: qd->qd_slot_count--; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);return -ENOSPC ; }
@@ -290,23 +288,23 @@ static void slot_hold(struct gfs2_quota_data *qd) {struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock);gfs2_assert (sdp, qd->qd_slot_count); qd->qd_slot_count++; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock); }static void slot_put (struct gfs2_quota_data *qd) {struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock);gfs2_assert (sdp, qd->qd_slot_count);if (!--qd->qd_slot_count) {gfs2_icbit_munge (sdp, sdp->sd_quota_bitmap, qd->qd_slot,0 ); qd->qd_slot =-1 ; } -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock); }static int bh_get (struct gfs2_quota_data *qd)
@@ -382,7 +380,6 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)return 0 ;spin_lock (&qd_lru_lock); -spin_lock (&sdp->sd_quota_spin);list_for_each_entry (qd, &sdp->sd_quota_list, qd_list) { if (test_bit(QDF_LOCKED, &qd->qd_flags) ||
@@ -406,7 +403,6 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)if (!found) qd =NULL ; -spin_unlock (&sdp->sd_quota_spin);spin_unlock (&qd_lru_lock);if (qd) {
@@ -433,11 +429,9 @@ static int qd_trylock(struct gfs2_quota_data *qd)return 0 ;spin_lock (&qd_lru_lock); -spin_lock (&sdp->sd_quota_spin);if (test_bit (QDF_LOCKED , &qd->qd_flags) || !test_bit (QDF_CHANGE , &qd->qd_flags)) { -spin_unlock (&sdp->sd_quota_spin);spin_unlock (&qd_lru_lock);return 0 ; }
@@ -451,7 +445,6 @@ static int qd_trylock(struct gfs2_quota_data *qd)gfs2_assert_warn (sdp, qd->qd_slot_count); qd->qd_slot_count++; -spin_unlock (&sdp->sd_quota_spin);spin_unlock (&qd_lru_lock);gfs2_assert_warn (sdp, qd->qd_change_sync);
@@ -612,9 +605,9 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change) x =be64_to_cpu (qc->qc_change) + change; qc->qc_change =cpu_to_be64 (x); -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock); qd->qd_change = x; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);if (!x) {gfs2_assert_warn (sdp,test_bit (QDF_CHANGE , &qd->qd_flags));
@@ -945,9 +938,9 @@ static int need_sync(struct gfs2_quota_data *qd)if (!qd->qd_qb.qb_limit)return 0 ; -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock); value = qd->qd_change; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);spin_lock (>->gt_spin); num = gt->gt_quota_scale_num;
@@ -1040,9 +1033,9 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)continue ; value = (s64 )be64_to_cpu (qd->qd_qb.qb_value); -spin_lock (&sdp->sd_quota_spin); +spin_lock (&qd_lru_lock); value += qd->qd_change; -spin_unlock (&sdp->sd_quota_spin); +spin_unlock (&qd_lru_lock);if (be64_to_cpu (qd->qd_qb.qb_limit) && (s64 )be64_to_cpu (qd->qd_qb.qb_limit) < value) {print_message (qd,"exceeded" );
@@ -1228,9 +1221,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) qd->qd_slot_count =1 ;spin_lock (&qd_lru_lock); -spin_lock (&sdp->sd_quota_spin);gfs2_icbit_munge (sdp, sdp->sd_quota_bitmap, slot,1 ); -spin_unlock (&sdp->sd_quota_spin);list_add (&qd->qd_list, &sdp->sd_quota_list);atomic_inc (&sdp->sd_quota_count);spin_unlock (&qd_lru_lock);
@@ -1263,18 +1254,15 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)while (!list_empty (head)) { qd = list_entry(head->prev, struct gfs2_quota_data, qd_list); -spin_lock (&sdp->sd_quota_spin);if (atomic_read (&qd->qd_count) >1 || (atomic_read (&qd->qd_count) && !test_bit (QDF_CHANGE , &qd->qd_flags))) { -spin_unlock (&sdp->sd_quota_spin);list_move (&qd->qd_list, head);spin_unlock (&qd_lru_lock);schedule ();spin_lock (&qd_lru_lock);continue ; } -spin_unlock (&sdp->sd_quota_spin);list_del (&qd->qd_list);/* Also remove if this qd exists in the reclaim list */
Signature · 1 line
1.6.0.3
PATCH 5/18 GFS2: Merge lock_dlm module into GFS2
From: Steven Whitehouse <[email protected]>
This is the big patch that I've been working on for some time now. There are many reasons for wanting to make this change such as:
o Reducing overhead by eliminating duplicated fields between structures
o Simplifcation of the code (reduces the code size by a fair bit)
o The locking interface is now the DLM interface itself as proposed some time ago.
o Fewer lookups of glocks when processing replies from the DLM
o Fewer memory allocations/deallocations for each glock
o Scope to do further optimisations in the future (but this patch is more than big enough for now!)
Please note that (a) this patch relates to the lock_dlm module and not the DLM itself, that is still a separate module; and (b) that we retain the ability to build GFS2 as a standalone single node filesystem with out requiring the DLM.
This patch needs a lot of testing, hence my keeping it I restarted my -git tree after the last merge window. That way, this has the maximum exposure before its merged. This is (modulo a few minor bug fixes) the same patch that I've been posting on and off the the last three months and its passed a number of different tests so far.
fs/gfs2/Kconfig +10 -7
@@ -1,6 +1,10 @@ config GFS2_FS tristate "GFS2 file system support" depends on EXPERIMENTAL && (64BIT || LBD) + select DLM if GFS2_FS_LOCKING_DLM + select CONFIGFS_FS if GFS2_FS_LOCKING_DLM + select SYSFS if GFS2_FS_LOCKING_DLM + select IP_SCTP if DLM_SCTP select FS_POSIX_ACL select CRC32 help
@@ -18,17 +22,16 @@ config GFS2_FS the locking module below. Documentation and utilities for GFS2 can be found here: http://sources.redhat.com/cluster - The "nolock" lock module is now built in to GFS2 by default. + The "nolock" lock module is now built in to GFS2 by default. If + you want to use the DLM, be sure to enable HOTPLUG and IPv4/6 + networking. config GFS2_FS_LOCKING_DLM - tristate "GFS2 DLM locking module" - depends on GFS2_FS && SYSFS && NET && INET && (IPV6 || IPV6=n) - select IP_SCTP if DLM_SCTP - select CONFIGFS_FS - select DLM + bool "GFS2 DLM locking" + depends on (GFS2_FS!=n) && NET && INET && (IPV6 || IPV6=n) && HOTPLUG help Multiple node locking module for GFS2 - Most users of GFS2 will require this module. It provides the locking + Most users of GFS2 will require this. It provides the locking interface between GFS2 and the DLM, which is required to use GFS2 in a cluster environment.
fs/gfs2/Makefile +2 -2
@@ -1,9 +1,9 @@ obj-$(CONFIG_GFS2_FS) += gfs2.o gfs2-y := acl.o bmap.o dir.o eaops.o eattr.o glock.o \ - glops.o inode.o log.o lops.o locking.o main.o meta_io.o \ + glops.o inode.o log.o lops.o main.o meta_io.o \ mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ ops_fstype.o ops_inode.o ops_super.o quota.o \ recovery.o rgrp.o super.o sys.o trans.o util.o -obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/ +gfs2-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o
fs/gfs2/acl.c +0 -1
@@ -15,7 +15,6 @@#include <linux/posix_acl.h> #include <linux/posix_acl_xattr.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/bmap.c +0 -1
@@ -13,7 +13,6 @@#include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/dir.c +0 -1
@@ -60,7 +60,6 @@#include <linux/gfs2_ondisk.h> #include <linux/crc32.h> #include <linux/vmalloc.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/eaops.c +0 -1
@@ -14,7 +14,6 @@#include <linux/capability.h> #include <linux/xattr.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <asm/uaccess.h> #include "gfs2.h"
fs/gfs2/eattr.c +0 -1
@@ -13,7 +13,6 @@#include <linux/buffer_head.h> #include <linux/xattr.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <asm/uaccess.h> #include "gfs2.h"
fs/gfs2/glock.c +75 -174
390 lines not on this page · raw message
fs/gfs2/glock.h +123 -4
152 lines not on this page · raw message
fs/gfs2/glops.c +0 -14
@@ -12,7 +12,6 @@#include <linux/completion.h> #include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <linux/bio.h> #include "gfs2.h"
@@ -390,18 +389,6 @@ static int trans_go_demote_ok(const struct gfs2_glock *gl)return 0 ; } -/** -* quota_go_demote_ok - Check to see if it's ok to unlock a quota glock -* @gl: the glock -* -* Returns: 1 if it's ok -*/ - -static int quota_go_demote_ok (const struct gfs2_glock *gl) -{ -return !atomic_read (&gl->gl_lvb_count); -} -const struct gfs2_glock_operations gfs2_meta_glops = { .go_xmote_th = meta_go_sync, .go_type =LM_TYPE_META ,
@@ -448,7 +435,6 @@ const struct gfs2_glock_operations gfs2_nondisk_glops = { };const struct gfs2_glock_operations gfs2_quota_glops = { - .go_demote_ok = quota_go_demote_ok, .go_type =LM_TYPE_QUOTA , };
fs/gfs2/incore.h +54 -5
101 lines not on this page · raw message
fs/gfs2/inode.c +6 -7
@@ -16,7 +16,6 @@#include <linux/sort.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> -#include <linux/lm_interface.h> #include <linux/security.h> #include <linux/time.h>
@@ -137,16 +136,16 @@ void gfs2_set_iop(struct inode *inode)if (S_ISREG (mode)) { inode->i_op = &gfs2_file_iops; -if (sdp->sd_args.ar_localflocks) - inode->i_fop = &gfs2_file_fops_nolock; +if (gfs2_localflocks (sdp)) + inode->i_fop = gfs2_file_fops_nolock;else - inode->i_fop = &gfs2_file_fops; + inode->i_fop = gfs2_file_fops; }else if (S_ISDIR (mode)) { inode->i_op = &gfs2_dir_iops; -if (sdp->sd_args.ar_localflocks) - inode->i_fop = &gfs2_dir_fops_nolock; +if (gfs2_localflocks (sdp)) + inode->i_fop = gfs2_dir_fops_nolock;else - inode->i_fop = &gfs2_dir_fops; + inode->i_fop = gfs2_dir_fops; }else if (S_ISLNK (mode)) { inode->i_op = &gfs2_symlink_iops; }else {
fs/gfs2/inode.h +18 -4
@@ -101,12 +101,26 @@ void gfs2_dinode_print(const struct gfs2_inode *ip);extern const struct inode_operations gfs2_file_iops;extern const struct inode_operations gfs2_dir_iops;extern const struct inode_operations gfs2_symlink_iops; -extern const struct file_operations gfs2_file_fops; -extern const struct file_operations gfs2_dir_fops; -extern const struct file_operations gfs2_file_fops_nolock; -extern const struct file_operations gfs2_dir_fops_nolock; +extern const struct file_operations *gfs2_file_fops_nolock; +extern const struct file_operations *gfs2_dir_fops_nolock;extern void gfs2_set_inode_flags (struct inode *inode); + +#ifdef CONFIG_GFS2_FS_LOCKING_DLM +extern const struct file_operations *gfs2_file_fops; +extern const struct file_operations *gfs2_dir_fops; +static inline int gfs2_localflocks (const struct gfs2_sbd *sdp) +{ +return sdp->sd_args.ar_localflocks; +} +#else /* Single node only */ +#define gfs2_file_fops NULL +#define gfs2_dir_fops NULL +static inline int gfs2_localflocks (const struct gfs2_sbd *sdp) +{ +return 1 ; +} +#endif /* CONFIG_GFS2_FS_LOCKING_DLM */ #endif /* __INODE_DOT_H__ */
fs/gfs2/lock_dlm.c new file +240 -0
240 lines not on this page · raw message
fs/gfs2/locking.c deleted +0 -314
314 lines not on this page · raw message
fs/gfs2/locking/dlm/Makefile deleted +0 -3
@@ -1,3 +0,0 @@ -obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o -lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o -
fs/gfs2/locking/dlm/lock.c deleted +0 -708
708 lines not on this page · raw message
fs/gfs2/locking/dlm/lock_dlm.h deleted +0 -166
166 lines not on this page · raw message
fs/gfs2/locking/dlm/main.c deleted +0 -48
48 lines not on this page · raw message
fs/gfs2/locking/dlm/mount.c deleted +0 -276
276 lines not on this page · raw message
fs/gfs2/locking/dlm/sysfs.c deleted +0 -226
226 lines not on this page · raw message
fs/gfs2/locking/dlm/thread.c deleted +0 -68
68 lines not on this page · raw message
fs/gfs2/log.c +0 -1
@@ -14,7 +14,6 @@#include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> -#include <linux/lm_interface.h> #include <linux/delay.h> #include <linux/kthread.h> #include <linux/freezer.h>
fs/gfs2/lops.c +0 -1
@@ -13,7 +13,6 @@#include <linux/completion.h> #include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/main.c +0 -3
@@ -14,7 +14,6 @@#include <linux/module.h> #include <linux/init.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <asm/atomic.h> #include "gfs2.h"
@@ -47,8 +46,6 @@ static void gfs2_init_glock_once(void *foo)INIT_HLIST_NODE (&gl->gl_list);spin_lock_init (&gl->gl_spin);INIT_LIST_HEAD (&gl->gl_holders); - gl->gl_lvb =NULL ; -atomic_set (&gl->gl_lvb_count,0 );INIT_LIST_HEAD (&gl->gl_lru);INIT_LIST_HEAD (&gl->gl_ail_list);atomic_set (&gl->gl_ail_count,0 );
fs/gfs2/meta_io.c +0 -1
@@ -19,7 +19,6 @@#include <linux/delay.h> #include <linux/bio.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/mount.c +0 -1
@@ -12,7 +12,6 @@#include <linux/completion.h> #include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <linux/parser.h> #include "gfs2.h"
fs/gfs2/ops_address.c +0 -1
@@ -19,7 +19,6 @@#include <linux/writeback.h> #include <linux/swap.h> #include <linux/gfs2_ondisk.h> -#include <linux/lm_interface.h> #include <linux/backing-dev.h> #include "gfs2.h"
fs/gfs2/ops_dentry.c +0 -1
@@ -13,7 +13,6 @@#include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/ops_export.c +0 -1
@@ -14,7 +14,6 @@#include <linux/exportfs.h> #include <linux/gfs2_ondisk.h> #include <linux/crc32.h> -#include <linux/lm_interface.h> #include "gfs2.h" #include "incore.h"
fs/gfs2/ops_file.c +22 -52
74 lines not on this page · raw message
fs/gfs2/ops_fstype.c +94 -40
134 lines not on this page · raw message
fs/gfs2/sys.c +148 -6
154 lines not on this page · raw message
include/linux/lm_interface.h deleted +0 -277
277 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.0.3
Part of the diff is not shown here. View the raw message.
PATCH 6/18 GFS2: Remove unused field from glock
From: Steven Whitehouse <[email protected]>
The time stamp field is unused in the glock now that we are using a shrinker, so that we can remove it and save sizeof(unsigned long) bytes in each glock.
fs/gfs2/glock.c +0 -2
@@ -700,7 +700,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,snprintf (gl->gl_strname,GDLM_STRNAME_BYTES ,"%8x%16llx" , name.ln_type, (unsigned long long )number);memset (&gl->gl_lksb,0 ,sizeof (struct dlm_lksb )); gl->gl_lksb.sb_lvbptr = gl->gl_lvb; - gl->gl_stamp = jiffies; gl->gl_tchange = jiffies; gl->gl_object =NULL ; gl->gl_sbd = sdp;
@@ -1008,7 +1007,6 @@ void gfs2_glock_dq(struct gfs2_holder *gh)spin_lock (&gl->gl_spin);clear_bit (GLF_LOCK , &gl->gl_flags); } - gl->gl_stamp = jiffies;if (list_empty (&gl->gl_holders) && !test_bit (GLF_PENDING_DEMOTE , &gl->gl_flags) && !test_bit (GLF_DEMOTE , &gl->gl_flags))
fs/gfs2/incore.h +0 -1
@@ -211,7 +211,6 @@ struct gfs2_glock {char gl_strname[GDLM_STRNAME_BYTES ];struct dlm_lksb gl_lksb;char gl_lvb[32 ]; -unsigned long gl_stamp;unsigned long gl_tchange;void *gl_object;
Signature · 1 line
1.6.0.3
PATCH 7/18 GFS2: Fix error path ref counting for root inode
From: Steven Whitehouse <[email protected]>
We were keeping hold of an extra ref to the root inode in one of the error paths, that resulted in a hang.
fs/gfs2/ops_fstype.c +2 -0
@@ -1258,6 +1258,8 @@ fail_sb:dput (sdp->sd_root_dir);if (sdp->sd_master_dir)dput (sdp->sd_master_dir); +if (sb->s_root) +dput (sb->s_root); sb->s_root =NULL ; fail_locking:init_locking (sdp, &mount_gh,UNDO );
Signature · 1 line
1.6.0.3
PATCH 8/18 GFS2: Fix deadlock on journal flush
From: Steven Whitehouse <[email protected]>
This patch fixes a deadlock when the journal is flushed and there are dirty inodes other than the one which caused the journal flush. Originally the journal flushing code was trying to obtain the transaction glock while running the flush code for an inode glock. We no longer require the transaction glock at this point in time since we know that any attempt to get the transaction glock from another node will result in a journal flush. So if we are flushing the journal, we can be sure that the transaction lock is still cached from when the transaction was started.
By inlining a version of gfs2_trans_begin() (minus the bit which gets the transaction glock) we can avoid the deadlock problems caused if there is a demote request queued up on the transaction glock.
In addition I've also moved the umount rwsem so that it covers the glock workqueue, since it all demotions are done by this workqueue now. That fixes a bug on umount which I came across while fixing the original problem.
fs/gfs2/glock.c +12 -14
@@ -167,6 +167,7 @@ static void glock_free(struct gfs2_glock *gl)static void gfs2_glock_hold (struct gfs2_glock *gl) { +GLOCK_BUG_ON (gl,atomic_read (&gl->gl_ref) ==0 );atomic_inc (&gl->gl_ref); }
@@ -206,16 +207,15 @@ int gfs2_glock_put(struct gfs2_glock *gl)atomic_dec (&lru_count); }spin_unlock (&lru_lock); -GLOCK_BUG_ON (gl, !list_empty (&gl->gl_lru));GLOCK_BUG_ON (gl, !list_empty (&gl->gl_holders));glock_free (gl); rv =1 ; goto out; } -write_unlock (gl_lock_addr (gl->gl_hash));/* 1 for being hashed, 1 for having state != LM_ST_UNLOCKED */ if (atomic_read (&gl->gl_ref) ==2 )gfs2_glock_schedule_for_reclaim (gl); +write_unlock (gl_lock_addr (gl->gl_hash)); out:return rv; }
@@ -597,10 +597,11 @@ __acquires(&gl->gl_spin)GLOCK_BUG_ON (gl,test_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags)); +down_read (&gfs2_umount_flush_sem);if (test_bit (GLF_DEMOTE , &gl->gl_flags) && gl->gl_demote_state != gl->gl_state) {if (find_first_holder (gl)) - goto out; + goto out_unlock;if (nonblock) goto out_sched;set_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags);
@@ -611,23 +612,26 @@ __acquires(&gl->gl_spin)gfs2_demote_wake (gl); ret =do_promote (gl);if (ret ==0 ) - goto out; + goto out_unlock;if (ret ==2 ) -return ; + goto out_sem; gh =find_first_waiter (gl); gl->gl_target = gh->gh_state;if (!(gh->gh_flags & (LM_FLAG_TRY |LM_FLAG_TRY_1CB )))do_error (gl,0 );/* Fail queued try locks */ }do_xmote (gl, gh, gl->gl_target); +out_sem: +up_read (&gfs2_umount_flush_sem);return ; out_sched:gfs2_glock_hold (gl);if (queue_delayed_work (glock_workqueue, &gl->gl_work,0 ) ==0 )gfs2_glock_put (gl); -out: +out_unlock:clear_bit (GLF_LOCK , &gl->gl_flags); + goto out_sem; }static void glock_work_func (struct work_struct *work)
@@ -1225,7 +1229,6 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)void gfs2_glock_complete (struct gfs2_glock *gl,int ret) {struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; -down_read (&gfs2_umount_flush_sem); gl->gl_reply = ret;if (unlikely (test_bit (DFL_BLOCK_LOCKS , &ls->ls_flags))) {struct gfs2_holder *gh;
@@ -1236,16 +1239,13 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret) ((ret & ~LM_OUT_ST_MASK) != 0))set_bit (GLF_FROZEN , &gl->gl_flags);spin_unlock (&gl->gl_spin); -if (test_bit (GLF_FROZEN , &gl->gl_flags)) { -up_read (&gfs2_umount_flush_sem); +if (test_bit (GLF_FROZEN , &gl->gl_flags))return ; - } }set_bit (GLF_REPLY_PENDING , &gl->gl_flags);gfs2_glock_hold (gl);if (queue_delayed_work (glock_workqueue, &gl->gl_work,0 ) ==0 )gfs2_glock_put (gl); -up_read (&gfs2_umount_flush_sem); }/**
@@ -1389,12 +1389,10 @@ static void thaw_glock(struct gfs2_glock *gl) {if (!test_and_clear_bit (GLF_FROZEN , &gl->gl_flags))return ; -down_read (&gfs2_umount_flush_sem);set_bit (GLF_REPLY_PENDING , &gl->gl_flags);gfs2_glock_hold (gl);if (queue_delayed_work (glock_workqueue, &gl->gl_work,0 ) ==0 )gfs2_glock_put (gl); -up_read (&gfs2_umount_flush_sem); }/**
@@ -1580,7 +1578,7 @@ static const char *gflags2str(char *buf, const unsigned long *gflags)if (test_bit (GLF_REPLY_PENDING , gflags)) *p++ ='r' ;if (test_bit (GLF_INITIAL , gflags)) - *p++ ='i' ; + *p++ ='I' ;if (test_bit (GLF_FROZEN , gflags)) *p++ ='F' ; *p =0 ;
fs/gfs2/glops.c +12 -7
@@ -37,20 +37,25 @@static void gfs2_ail_empty_gl (struct gfs2_glock *gl) {struct gfs2_sbd *sdp = gl->gl_sbd; -unsigned int blocks;struct list_head *head = &gl->gl_ail_list;struct gfs2_bufdata *bd;struct buffer_head *bh; -int error; +struct gfs2_trans tr; - blocks =atomic_read (&gl->gl_ail_count); -if (!blocks) -return ; +memset (&tr,0 ,sizeof (tr)); + tr.tr_revokes =atomic_read (&gl->gl_ail_count); - error =gfs2_trans_begin (sdp,0 , blocks); -if (gfs2_assert_withdraw (sdp, !error)) +if (!tr.tr_revokes)return ; +/* A shortened, inline version of gfs2_trans_begin() */ + tr.tr_reserved =1 +gfs2_struct2blk (sdp, tr.tr_revokes,sizeof (u64)); + tr.tr_ip = (unsigned long )__builtin_return_address (0 ); +INIT_LIST_HEAD (&tr.tr_list_buf); +gfs2_log_reserve (sdp, tr.tr_reserved); +BUG_ON (current->journal_info); + current->journal_info = &tr; +gfs2_log_lock (sdp);while (!list_empty (head)) { bd = list_entry(head->next, struct gfs2_bufdata,
fs/gfs2/trans.c +10 -6
@@ -87,9 +87,11 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)if (!tr->tr_touched) {gfs2_log_release (sdp, tr->tr_reserved); -gfs2_glock_dq (&tr->tr_t_gh); -gfs2_holder_uninit (&tr->tr_t_gh); -kfree (tr); +if (tr->tr_t_gh.gh_gl) { +gfs2_glock_dq (&tr->tr_t_gh); +gfs2_holder_uninit (&tr->tr_t_gh); +kfree (tr); + }return ; }
@@ -105,9 +107,11 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) }gfs2_log_commit (sdp, tr); -gfs2_glock_dq (&tr->tr_t_gh); -gfs2_holder_uninit (&tr->tr_t_gh); -kfree (tr); +if (tr->tr_t_gh.gh_gl) { +gfs2_glock_dq (&tr->tr_t_gh); +gfs2_holder_uninit (&tr->tr_t_gh); +kfree (tr); + }if (sdp->sd_vfs->s_flags &MS_SYNCHRONOUS )gfs2_log_flush (sdp,NULL );
Signature · 1 line
1.6.0.3
PATCH 9/18 GFS2: Support generation of discard requests
From: Steven Whitehouse <[email protected]>
This patch allows GFS2 to generate discard requests for blocks which are no longer useful to the filesystem (i.e. those which have been freed as the result of an unlink operation). The requests are generated at the time which those blocks become available for reuse in the filesystem.
In order to use this new feature, you have to specify the "discard" mount option. The code coalesces adjacent blocks into a single extent when generating the discard requests, thus generating the minimum number.
If an error occurs when the request has been sent to the block device, then it will print a message and turn off the requests for that filesystem. If the problem is temporary, then you can use remount to turn the option back on again. There is also a nodiscard mount option so that you can use remount to turn discard requests off, if required.
fs/gfs2/incore.h +1 -1
@@ -416,7 +416,7 @@ struct gfs2_args { unsigned int ar_suiddir:1; /* suiddir support */ unsigned int ar_data:2; /* ordered/writeback */ unsigned int ar_meta:1; /* mount metafs */ -unsigned int ar_num_glockd;/* Number of glockd threads */ + unsigned int ar_discard:1; /* discard requests */ };struct gfs2_tune {
fs/gfs2/mount.c +10 -0
@@ -41,6 +41,8 @@ enum { Opt_data_writeback, Opt_data_ordered, Opt_meta, + Opt_discard, + Opt_nodiscard, Opt_err, };
@@ -65,6 +67,8 @@ static const match_table_t tokens = { {Opt_data_writeback, "data=writeback"}, {Opt_data_ordered, "data=ordered"}, {Opt_meta, "meta"}, + {Opt_discard, "discard"}, + {Opt_nodiscard, "nodiscard"}, {Opt_err, NULL} };
@@ -157,6 +161,12 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)case Opt_meta: args->ar_meta =1 ;break ; +case Opt_discard: + args->ar_discard =1 ; +break ; +case Opt_nodiscard: + args->ar_discard =0 ; +break ;case Opt_err:default :fs_info (sdp,"invalid mount option: %s\n" , o);
fs/gfs2/ops_super.c +2 -0
@@ -608,6 +608,8 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) }seq_printf (s,",data=%s" , state); } +if (args->ar_discard) +seq_printf (s,",discard" );return 0 ; }
fs/gfs2/rgrp.c +55 -0
73 lines not on this page · raw message
Signature · 1 line
1.6.0.3
PATCH 10/18 GFS2: Expose UUID via sysfs/uevent
From: Steven Whitehouse <[email protected]>
Since we have a UUID, we ought to expose it to the user via sysfs and uevents. We already have the fs name in both of these places (a combination of the lock proto and lock table name) so if we add the UUID as well, we have a full set.
For older filesystems (i.e. those created before mkfs.gfs2 was writing UUIDs by default) the sysfs file will appear zero length, and no UUID env var will be added to the uevents.
fs/gfs2/incore.h +1 -0
@@ -470,6 +470,7 @@ struct gfs2_sb_host {char sb_lockproto[GFS2_LOCKNAME_LEN ];char sb_locktable[GFS2_LOCKNAME_LEN ]; +u8 sb_uuid[16 ]; };/*
fs/gfs2/ops_fstype.c +1 -0
@@ -234,6 +234,7 @@ static void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf)memcpy (sb->sb_lockproto, str->sb_lockproto,GFS2_LOCKNAME_LEN );memcpy (sb->sb_locktable, str->sb_locktable,GFS2_LOCKNAME_LEN ); +memcpy (sb->sb_uuid, str->sb_uuid,16 ); }/**
fs/gfs2/sys.c +37 -0
@@ -36,6 +36,30 @@ static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)return snprintf (buf,PAGE_SIZE ,"%s\n" , sdp->sd_fsname); } +static int gfs2_uuid_valid (const u8 *uuid) +{ +int i; + +for (i =0 ; i <16 ; i++) { +if (uuid[i]) +return 1 ; + } +return 0 ; +} + +static ssize_t uuid_show (struct gfs2_sbd *sdp,char *buf) +{ +const u8 *uuid = sdp->sd_sb.sb_uuid; + buf[0 ] ='\0' ; +if (!gfs2_uuid_valid (uuid)) +return 0 ; +return snprintf (buf,PAGE_SIZE ,"%02X%02X%02X%02X-%02X%02X-" +"%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n" , + uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], uuid[5 ], + uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], + uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ]); +} +static ssize_t freeze_show (struct gfs2_sbd *sdp,char *buf) {unsigned int count;
@@ -158,6 +182,7 @@ static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)GFS2_ATTR (id,0444 , id_show,NULL );GFS2_ATTR (fsname,0444 , fsname_show,NULL ); +GFS2_ATTR (uuid,0444 , uuid_show,NULL );GFS2_ATTR (freeze,0644 , freeze_show, freeze_store);GFS2_ATTR (withdraw,0644 , withdraw_show, withdraw_store);GFS2_ATTR (statfs_sync,0200 ,NULL , statfs_sync_store);
@@ -168,6 +193,7 @@ GFS2_ATTR(quota_refresh_group, 0200, NULL, quota_refresh_group_store);static struct attribute *gfs2_attrs[] = { &gfs2_attr_id.attr, &gfs2_attr_fsname.attr, + &gfs2_attr_uuid.attr, &gfs2_attr_freeze.attr, &gfs2_attr_withdraw.attr, &gfs2_attr_statfs_sync.attr,
@@ -598,12 +624,23 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp)kobject_put (&sdp->sd_kobj); } +static int gfs2_uevent (struct kset *kset,struct kobject *kobj,struct kobj_uevent_env *env) { struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); +const u8 *uuid = sdp->sd_sb.sb_uuid; +add_uevent_var (env,"LOCKTABLE=%s" , sdp->sd_table_name);add_uevent_var (env,"LOCKPROTO=%s" , sdp->sd_proto_name); +if (gfs2_uuid_valid (uuid)) { +add_uevent_var (env,"UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" +"%02X%02X-%02X%02X%02X%02X%02X%02X" , + uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], + uuid[5 ], uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], + uuid[10 ], uuid[11 ], uuid[12 ], uuid[13 ], + uuid[14 ], uuid[15 ]); + }return 0 ; }
Signature · 1 line
1.6.0.3
PATCH 11/18 GFS2: Add a "demote a glock" interface to sysfs
From: Steven Whitehouse <[email protected]>
This adds a sysfs file called demote_rq to GFS2's per filesystem directory. Its possible to use this file to demote arbitrary glocks in exactly the same way as if a request had come in from a remote node.
This is intended for testing issues relating to caching of data under glocks. Despite that, the interface is generic enough to send requests to any type of glock, but be careful as its not always safe to send an arbitrary message to an arbitrary glock. For that reason and to prevent DoS, this interface is restricted to root only.
The messages look like this:
<type>:<glocknumber> <mode>
Example:
echo -n "2:13324 EX" >/sys/fs/gfs2/unity:myfs/demote_rq
Which means "please demote inode glock (type 2) number 13324 so that I can get an EX (exclusive) lock". The lock modes are those which would normally be sent by a remote node in its callback so if you want to unlock a glock, you use EX, to demote to shared, use SH or PR (depending on whether you like GFS2 or DLM lock modes better!).
If the glock doesn't exist, you'll get -ENOENT returned. If the arguments don't make sense, you'll get -EINVAL returned.
The plan is that this interface will be used in combination with the blktrace patch which I recently posted for comments although it is, of course, still useful in its own right.
fs/gfs2/glock.c +4 -3
@@ -684,10 +684,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, gl =search_bucket (hash, sdp, &name);read_unlock (gl_lock_addr (hash)); -if (gl || !create) { - *glp = gl; + *glp = gl; +if (gl)return 0 ; - } +if (!create) +return -ENOENT ; gl =kmem_cache_alloc (gfs2_glock_cachep,GFP_KERNEL );if (!gl)
fs/gfs2/glops.c +12 -0
@@ -447,3 +447,15 @@ const struct gfs2_glock_operations gfs2_journal_glops = { .go_type = LM_TYPE_JOURNAL, }; +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, + [LM_TYPE_QUOTA ] = &gfs2_quota_glops, + [LM_TYPE_JOURNAL ] = &gfs2_journal_glops, +}; +
fs/gfs2/glops.h +1 -0
@@ -21,5 +21,6 @@ extern const struct gfs2_glock_operations gfs2_flock_glops;extern const struct gfs2_glock_operations gfs2_nondisk_glops;extern const struct gfs2_glock_operations gfs2_quota_glops;extern const struct gfs2_glock_operations gfs2_journal_glops; +extern const struct gfs2_glock_operations *gfs2_glops_list[];#endif /* __GLOPS_DOT_H__ */
fs/gfs2/rgrp.c +1 -1
@@ -839,7 +839,7 @@ static void gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,const unsigned int sects_per_blk = sdp->sd_sb.sb_bsize /bdev_hardsect_size (sb->s_bdev);u64 blk; -sector_t start; +sector_t start =0 ;sector_t nr_sects =0 ;int rv;unsigned int x;
fs/gfs2/sys.c +43 -0
67 lines not on this page · raw message
Signature · 1 line
1.6.0.3
PATCH 12/18 GFS2: Fix alignment issue and tidy gfs2_bitfit
From: Steven Whitehouse <[email protected]>
An alignment issue with the existing bitfit algorithm was reported on IA64. This patch attempts to fix that, and also to tidy up the code a bit. There is now more documentation about how this works and it has survived a number of different tests.
fs/gfs2/rgrp.c +70 -62
@@ -132,81 +132,89 @@ static inline unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, }/** +* gfs2_bit_search +* @ptr: Pointer to bitmap data +* @mask: Mask to use (normally 0x55555.... but adjusted for search start) +* @state: The state we are searching for +* +* We xor the bitmap data with a patter which is the bitwise opposite +* of what we are looking for, this gives rise to a pattern of ones +* wherever there is a match. Since we have two bits per entry, we +* take this pattern, shift it down by one place and then and it with +* the original. All the even bit positions (0,2,4, etc) then represent +* successful matches, so we mask with 0x55555..... to remove the unwanted +* odd bit positions. +* +* This allows searching of a whole u64 at once (32 blocks) with a +* single test (on 64 bit arches). +*/ + +static inline u64 gfs2_bit_search (const __le64 *ptr,u64 mask,u8 state) +{ +u64 tmp; +static const u64 search[] = { + [0 ] =0xffffffffffffffff , + [1 ] =0xaaaaaaaaaaaaaaaa , + [2 ] =0x5555555555555555 , + [3 ] =0x0000000000000000 , + }; + tmp =le64_to_cpu (*ptr) ^ search[state]; + tmp &= (tmp >>1 ); + tmp &= mask; +return tmp; +} + +/** * gfs2_bitfit - Search an rgrp's bitmap buffer to find a bit-pair representing * a block in a given allocation state. * @buffer: the buffer that holds the bitmaps -* @buflen: the length (in bytes) of the buffer +* @len: the length (in bytes) of the buffer * @goal: start search at this block's bit-pair (within @buffer) -* @old_state: GFS2_BLKST_XXX the state of the block we're looking for. +* @state: GFS2_BLKST_XXX the state of the block we're looking for. * * Scope of @goal and returned block number is only within this bitmap buffer, * not entire rgrp or filesystem. @buffer will be offset from the actual -* beginning of a bitmap block buffer, skipping any header structures. +* beginning of a bitmap block buffer, skipping any header structures, but +* headers are always a multiple of 64 bits long so that the buffer is +* always aligned to a 64 bit boundary. +* +* The size of the buffer is in bytes, but is it assumed that it is +* always ok to to read a complete multiple of 64 bits at the end +* of the block in case the end is no aligned to a natural boundary. * * Return: the block number (bitmap buffer scope) that was found */ -static u32 gfs2_bitfit (const u8 *buffer,unsigned int buflen,u32 goal, -u8 old_state) +u32 gfs2_bitfit (const u8 *buf,const unsigned int len,u32 goal,u8 state) { -const u8 *byte, *start, *end; -int bit, startbit; -u32 g1, g2, misaligned; -unsigned long *plong; -unsigned long lskipval; - - lskipval = (old_state &GFS2_BLKST_USED ) ?LBITSKIP00 :LBITSKIP55 ; - g1 = (goal /GFS2_NBBY ); - start = buffer + g1; - byte = start; - end = buffer + buflen; - g2 =ALIGN (g1,sizeof (unsigned long )); - plong = (unsigned long *)(buffer + g2); - startbit = bit = (goal %GFS2_NBBY ) *GFS2_BIT_SIZE ; - misaligned = g2 - g1; -if (!misaligned) - goto ulong_aligned; -/* parse the bitmap a byte at a time */ -misaligned: -while (byte < end) { -if (((*byte >> bit) &GFS2_BIT_MASK ) == old_state) { -return goal + - (((byte - start) *GFS2_NBBY ) + - ((bit - startbit) >>1 )); - } - bit +=GFS2_BIT_SIZE ; -if (bit >=GFS2_NBBY *GFS2_BIT_SIZE ) { - bit =0 ; - byte++; - misaligned--; -if (!misaligned) { - plong = (unsigned long *)byte; - goto ulong_aligned; - } - } - } -return BFITNOENT ; - -/* parse the bitmap a unsigned long at a time */ -ulong_aligned: -/* Stop at "end - 1" or else prefetch can go past the end and segfault. -We could "if" it but we'd lose some of the performance gained. -This way will only slow down searching the very last 4/8 bytes -depending on architecture. I've experimented with several ways -of writing this section such as using an else before the goto -but this one seems to be the fastest. */ -while ((unsigned char *)plong < end -sizeof (unsigned long )) { -prefetch (plong +1 ); -if (((*plong) &LBITMASK ) != lskipval) -break ; - plong++; - } -if ((unsigned char *)plong < end) { - byte = (const u8 *)plong; - misaligned +=sizeof (unsigned long ) -1 ; - goto misaligned; +u32 spoint = (goal <<1 ) & ((8 *sizeof (u64)) -1 ); +const __le64 *ptr = ((__le64 *)buf) + (goal >>5 ); +const __le64 *end = (__le64 *)(buf +ALIGN (len,sizeof (u64))); +u64 tmp; +u64 mask =0x5555555555555555 ; +u32 bit; + +BUG_ON (state >3 ); + +/* Mask off bits we don't care about at the start of the search */ + mask <<= spoint; + tmp =gfs2_bit_search (ptr, mask, state); + ptr++; +while (tmp ==0 && ptr < end) { + tmp =gfs2_bit_search (ptr,0x5555555555555555 , state); + ptr++; } -return BFITNOENT ; +/* Mask off any bits which are more than len bytes from the start */ +if (ptr == end && (len & (sizeof (u64) -1 ))) + tmp &= (((u64 )~0 ) >> (64 -8 *(len & (sizeof (u64) -1 )))); +/* Didn't find anything, so return */ +if (tmp ==0 ) +return BFITNOENT ; + ptr--; + bit =fls64 (tmp); + bit--;/* fls64 always adds one to the bit count */ + bit /=2 ;/* two bits per entry in the bitmap */ +return (((const unsigned char *)ptr - buf) *GFS2_NBBY ) + bit; }/**
Signature · 1 line
1.6.0.3
PATCH 13/18 GFS2: Support quota/noquota mount arguments
From: Steven Whitehouse <[email protected]>
This adds support for "quota" and "noquota" mount options in addition to the existing "quota=on/off/account" so that we are compatible with the names by which these options are more generally known.
fs/gfs2/mount.c +6 -0
@@ -36,6 +36,8 @@ enum { Opt_quota_off, Opt_quota_account, Opt_quota_on, + Opt_quota, + Opt_noquota, Opt_suiddir, Opt_nosuiddir, Opt_data_writeback,
@@ -62,6 +64,8 @@ static const match_table_t tokens = { {Opt_quota_off, "quota=off"}, {Opt_quota_account, "quota=account"}, {Opt_quota_on, "quota=on"}, + {Opt_quota, "quota"}, + {Opt_noquota, "noquota"}, {Opt_suiddir, "suiddir"}, {Opt_nosuiddir, "nosuiddir"}, {Opt_data_writeback, "data=writeback"},
@@ -138,12 +142,14 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options) args->ar_posix_acl =0 ;break ;case Opt_quota_off: +case Opt_noquota: args->ar_quota =GFS2_QUOTA_OFF ;break ;case Opt_quota_account: args->ar_quota =GFS2_QUOTA_ACCOUNT ;break ;case Opt_quota_on: +case Opt_quota: args->ar_quota =GFS2_QUOTA_ON ;break ;case Opt_suiddir:
Signature · 1 line
1.6.0.3
PATCH 14/18 GFS2: fix sparse warnings: constant is so big it is ...
From: Hannes Eder <[email protected]>
Fix this sparse warnings:
fs/gfs2/rgrp.c:156:23: warning: constant 0xffffffffffffffff is so big it is unsigned long long fs/gfs2/rgrp.c:157:23: warning: constant 0xaaaaaaaaaaaaaaaa is so big it is unsigned long long fs/gfs2/rgrp.c:158:23: warning: constant 0x5555555555555555 is so big it is long long fs/gfs2/rgrp.c:194:20: warning: constant 0x5555555555555555 is so big it is long long fs/gfs2/rgrp.c:204:44: warning: constant 0x5555555555555555 is so big it is long long
fs/gfs2/rgrp.c +6 -6
@@ -153,10 +153,10 @@ static inline u64 gfs2_bit_search(const __le64 *ptr, u64 mask, u8 state) {u64 tmp;static const u64 search[] = { - [0 ] =0xffffffffffffffff , - [1 ] =0xaaaaaaaaaaaaaaaa , - [2 ] =0x5555555555555555 , - [3 ] =0x0000000000000000 , + [0 ] =0xffffffffffffffffULL , + [1 ] =0xaaaaaaaaaaaaaaaaULL , + [2 ] =0x5555555555555555ULL , + [3 ] =0x0000000000000000ULL , }; tmp =le64_to_cpu (*ptr) ^ search[state]; tmp &= (tmp >>1 );
@@ -191,7 +191,7 @@ u32 gfs2_bitfit(const u8 *buf, const unsigned int len, u32 goal, u8 state)const __le64 *ptr = ((__le64 *)buf) + (goal >>5 );const __le64 *end = (__le64 *)(buf +ALIGN (len,sizeof (u64)));u64 tmp; -u64 mask =0x5555555555555555 ; +u64 mask =0x5555555555555555ULL ;u32 bit;BUG_ON (state >3 );
@@ -201,7 +201,7 @@ u32 gfs2_bitfit(const u8 *buf, const unsigned int len, u32 goal, u8 state) tmp =gfs2_bit_search (ptr, mask, state); ptr++;while (tmp ==0 && ptr < end) { - tmp =gfs2_bit_search (ptr,0x5555555555555555 , state); + tmp =gfs2_bit_search (ptr,0x5555555555555555ULL , state); ptr++; }/* Mask off any bits which are more than len bytes from the start */
Signature · 1 line
1.6.0.3
PATCH 15/18 GFS2: fix sparse warning: Should it be static?
From: Hannes Eder <[email protected]>
Impact: Make symbol static.
Fix this sparse warning:
fs/gfs2/rgrp.c:188:5: warning: symbol 'gfs2_bitfit' was not declared. Should it be static?
fs/gfs2/rgrp.c +2 -1
@@ -185,7 +185,8 @@ static inline u64 gfs2_bit_search(const __le64 *ptr, u64 mask, u8 state)* Return: the block number (bitmap buffer scope) that was found */ -u32 gfs2_bitfit (const u8 *buf,const unsigned int len,u32 goal,u8 state) +static u32 gfs2_bitfit (const u8 *buf,const unsigned int len, +u32 goal,u8 state) {u32 spoint = (goal <<1 ) & ((8 *sizeof (u64)) -1 );const __le64 *ptr = ((__le64 *)buf) + (goal >>5 );
Signature · 1 line
1.6.0.3
PATCH 16/18 GFS2: Pagecache usage optimization on GFS2
From: Hisashi Hifumi <[email protected]>
I introduced "is_partially_uptodate" aops for GFS2.
A page can have multiple buffers and even if a page is not uptodate, some buffers can be uptodate on pagesize != blocksize environment.
This aops checks that all buffers which correspond to a part of a file that we want to read are uptodate. If so, we do not have to issue actual read IO to HDD even if a page is not uptodate because the portion we want to read are uptodate.
"block_is_partially_uptodate" function is already used by ext2/3/4. With the following patch random read/write mixed workloads or random read after random write workloads can be optimized and we can get performance improvement.
I did a performance test using the sysbench.
#sysbench --num-threads=16 --max-requests=200000 --test=fileio --file-num=1 --file-block-size=8K --file-total-size=2G --file-test-mode=rndrw --file-fsync-freq=0 --file-rw-ratio=1 run
-2.6.29-rc6
Test execution summary:
total time: 202.6389s
total number of events: 200000
total time taken by event execution: 2580.0480 per-request statistics:
min: 0.0000s
avg: 0.0129s
max: 49.5852s
approx. 95 percentile: 0.0462s
-2.6.29-rc6-patched
Test execution summary:
total time: 177.8639s
total number of events: 200000
total time taken by event execution: 2419.0199 per-request statistics:
min: 0.0000s
avg: 0.0121s
max: 52.4306s
approx. 95 percentile: 0.0444s
arch: ia64
pagesize: 16k
blocksize: 4k
fs/gfs2/ops_address.c +3 -0
@@ -1096,6 +1096,7 @@ static const struct address_space_operations gfs2_writeback_aops = { .releasepage = gfs2_releasepage, .direct_IO = gfs2_direct_IO, .migratepage = buffer_migrate_page, + .is_partially_uptodate = block_is_partially_uptodate, };static const struct address_space_operations gfs2_ordered_aops = {
@@ -1111,6 +1112,7 @@ static const struct address_space_operations gfs2_ordered_aops = { .releasepage = gfs2_releasepage, .direct_IO = gfs2_direct_IO, .migratepage = buffer_migrate_page, + .is_partially_uptodate = block_is_partially_uptodate, };static const struct address_space_operations gfs2_jdata_aops = {
@@ -1125,6 +1127,7 @@ static const struct address_space_operations gfs2_jdata_aops = { .bmap = gfs2_bmap, .invalidatepage = gfs2_invalidatepage, .releasepage = gfs2_releasepage, + .is_partially_uptodate = block_is_partially_uptodate, };void gfs2_set_aops (struct inode *inode)
Signature · 1 line
1.6.0.3
PATCH 17/18 GFS2: Fix locking bug in failed shared to exclusive conversion
From: Benjamin Marzinski <[email protected]>
After calling out to the dlm, GFS2 sets the new state of a glock to gl_target in gdlm_ast(). However, gl_target is not always the lock state that was requested. If a conversion from shared to exclusive fails, finish_xmote() will call do_xmote() with LM_ST_UNLOCKED, instead of gl->gl_target, so that it can reacquire the lock in exlusive the next time around. In this case, setting the lock to gl_target in gdlm_ast() will make GFS2 think that it has the glock in exclusive mode, when really, it doesn't have the glock locked at all. This patch adds a new field to the gfs2_glock structure, gl_req, to track the mode that was requested.
fs/gfs2/incore.h +1 -0
@@ -203,6 +203,7 @@ struct gfs2_glock {unsigned int gl_target;unsigned int gl_reply;unsigned int gl_hash; +unsigned int gl_req;unsigned int gl_demote_state;/* state requested by remote node */ unsigned long gl_demote_time;/* time of first demote request */ struct list_head gl_holders;
fs/gfs2/lock_dlm.c +4 -3
@@ -46,11 +46,11 @@ static void gdlm_ast(void *arg)BUG (); } - ret = gl->gl_target; + ret = gl->gl_req;if (gl->gl_lksb.sb_flags &DLM_SBF_ALTMODE ) { -if (gl->gl_target ==LM_ST_SHARED ) +if (gl->gl_req ==LM_ST_SHARED ) ret =LM_ST_DEFERRED ; -else if (gl->gl_target ==LM_ST_DEFERRED ) +else if (gl->gl_req ==LM_ST_DEFERRED ) ret =LM_ST_SHARED ;else BUG ();
@@ -147,6 +147,7 @@ static unsigned int gdlm_lock(struct gfs2_glock *gl,int req;u32 lkf; + gl->gl_req = req_state; req =make_mode (req_state); lkf =make_flags (gl->gl_lksb.sb_lkid, flags, req);
Signature · 1 line
1.6.0.3
PATCH 18/18 GFS2: Clean up of glops.c
From: Steven Whitehouse <[email protected]>
This cleans up a number of bits of code mostly based in glops.c. A couple of simple functions have been merged into the callers to make it more obvious what is going on, the mysterious raising of i_writecount around the truncate_inode_pages() call has been removed. The meta_go_* operations have been renamed rgrp_go_* since that is the only lock type that they are used with.
The unused argument of gfs2_read_sb has been removed. Also a bug has been fixed where a check for the rindex inode was in the wrong callback. More comments are added, and the debugging code is improved too.
fs/gfs2/glops.c +52 -63
@@ -76,29 +76,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl) }/** -* gfs2_pte_inval - Sync and invalidate all PTEs associated with a glock -* @gl: the glock -* -*/ - -static void gfs2_pte_inval (struct gfs2_glock *gl) -{ -struct gfs2_inode *ip; -struct inode *inode; - - ip = gl->gl_object; - inode = &ip->i_inode; -if (!ip || !S_ISREG (inode->i_mode)) -return ; - -unmap_shared_mapping_range (inode->i_mapping,0 ,0 ); -if (test_bit (GIF_SW_PAGED , &ip->i_flags)) -set_bit (GLF_DIRTY , &gl->gl_flags); - -} - -/** -* meta_go_sync - sync out the metadata for this glock +* rgrp_go_sync - sync out the metadata for this glock * @gl: the glock * * Called when demoting or unlocking an EX glock. We must flush
@@ -106,36 +84,42 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)* not return to caller to demote/unlock the glock until I/O is complete. */ -static void meta_go_sync (struct gfs2_glock *gl) +static void rgrp_go_sync (struct gfs2_glock *gl) { -if (gl->gl_state !=LM_ST_EXCLUSIVE ) +struct address_space *metamapping = gl->gl_aspace->i_mapping; +int error; + +if (!test_and_clear_bit (GLF_DIRTY , &gl->gl_flags))return ; +BUG_ON (gl->gl_state !=LM_ST_EXCLUSIVE ); -if (test_and_clear_bit (GLF_DIRTY , &gl->gl_flags)) { -gfs2_log_flush (gl->gl_sbd, gl); -gfs2_meta_sync (gl); -gfs2_ail_empty_gl (gl); - } +gfs2_log_flush (gl->gl_sbd, gl); +filemap_fdatawrite (metamapping); + error =filemap_fdatawait (metamapping); +mapping_set_error (metamapping, error); +gfs2_ail_empty_gl (gl); }/** -* meta_go_inval - invalidate the metadata for this glock +* rgrp_go_inval - invalidate the metadata for this glock * @gl: the glock * @flags: * +* We never used LM_ST_DEFERRED with resource groups, so that we +* should always see the metadata flag set here. +* */ -static void meta_go_inval (struct gfs2_glock *gl,int flags) +static void rgrp_go_inval (struct gfs2_glock *gl,int flags) { -if (!(flags &DIO_METADATA )) -return ; +struct address_space *mapping = gl->gl_aspace->i_mapping; -gfs2_meta_inval (gl); -if (gl->gl_object ==GFS2_I (gl->gl_sbd->sd_rindex)) - gl->gl_sbd->sd_rindex_uptodate =0 ; -else if (gl->gl_ops == &gfs2_rgrp_glops && gl->gl_object) { -struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object; +BUG_ON (!(flags &DIO_METADATA )); +gfs2_assert_withdraw (gl->gl_sbd, !atomic_read (&gl->gl_ail_count)); +truncate_inode_pages (mapping,0 ); +if (gl->gl_object) { +struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object; rgd->rd_flags &= ~GFS2_RDF_UPTODATE ; } }
@@ -152,48 +136,54 @@ static void inode_go_sync(struct gfs2_glock *gl)struct address_space *metamapping = gl->gl_aspace->i_mapping;int error; -if (gl->gl_state !=LM_ST_UNLOCKED ) -gfs2_pte_inval (gl); -if (gl->gl_state !=LM_ST_EXCLUSIVE ) -return ; -if (ip && !S_ISREG (ip->i_inode.i_mode)) ip =NULL ; +if (ip &&test_and_clear_bit (GIF_SW_PAGED , &ip->i_flags)) +unmap_shared_mapping_range (ip->i_inode.i_mapping,0 ,0 ); +if (!test_and_clear_bit (GLF_DIRTY , &gl->gl_flags)) +return ; -if (test_bit (GLF_DIRTY , &gl->gl_flags)) { -gfs2_log_flush (gl->gl_sbd, gl); -filemap_fdatawrite (metamapping); -if (ip) { -struct address_space *mapping = ip->i_inode.i_mapping; -filemap_fdatawrite (mapping); - error =filemap_fdatawait (mapping); -mapping_set_error (mapping, error); - } - error =filemap_fdatawait (metamapping); -mapping_set_error (metamapping, error); -clear_bit (GLF_DIRTY , &gl->gl_flags); -gfs2_ail_empty_gl (gl); +BUG_ON (gl->gl_state !=LM_ST_EXCLUSIVE ); + +gfs2_log_flush (gl->gl_sbd, gl); +filemap_fdatawrite (metamapping); +if (ip) { +struct address_space *mapping = ip->i_inode.i_mapping; +filemap_fdatawrite (mapping); + error =filemap_fdatawait (mapping); +mapping_set_error (mapping, error); } + error =filemap_fdatawait (metamapping); +mapping_set_error (metamapping, error); +gfs2_ail_empty_gl (gl); }/** * inode_go_inval - prepare a inode glock to be released * @gl: the glock * @flags: +* +* Normally we invlidate everything, but if we are moving into +* LM_ST_DEFERRED from LM_ST_SHARED or LM_ST_EXCLUSIVE then we +* can keep hold of the metadata, since it won't have changed. * */ static void inode_go_inval (struct gfs2_glock *gl,int flags) {struct gfs2_inode *ip = gl->gl_object; -int meta = (flags &DIO_METADATA ); -if (meta) { -gfs2_meta_inval (gl); +gfs2_assert_withdraw (gl->gl_sbd, !atomic_read (&gl->gl_ail_count)); + +if (flags &DIO_METADATA ) { +struct address_space *mapping = gl->gl_aspace->i_mapping; +truncate_inode_pages (mapping,0 );if (ip)set_bit (GIF_INVALID , &ip->i_flags); } +if (ip ==GFS2_I (gl->gl_sbd->sd_rindex)) + gl->gl_sbd->sd_rindex_uptodate =0 ;if (ip &&S_ISREG (ip->i_inode.i_mode))truncate_inode_pages (ip->i_inode.i_mapping,0 ); }
@@ -395,7 +385,6 @@ static int trans_go_demote_ok(const struct gfs2_glock *gl) }const struct gfs2_glock_operations gfs2_meta_glops = { - .go_xmote_th = meta_go_sync, .go_type =LM_TYPE_META , };
@@ -410,8 +399,8 @@ const struct gfs2_glock_operations gfs2_inode_glops = { };const struct gfs2_glock_operations gfs2_rgrp_glops = { - .go_xmote_th = meta_go_sync, - .go_inval = meta_go_inval, + .go_xmote_th = rgrp_go_sync, + .go_inval = rgrp_go_inval, .go_demote_ok = rgrp_go_demote_ok, .go_lock = rgrp_go_lock, .go_unlock = rgrp_go_unlock,
fs/gfs2/meta_io.c +0 -21
@@ -89,27 +89,6 @@ void gfs2_aspace_put(struct inode *aspace) }/** -* gfs2_meta_inval - Invalidate all buffers associated with a glock -* @gl: the glock -* -*/ - -void gfs2_meta_inval (struct gfs2_glock *gl) -{ -struct gfs2_sbd *sdp = gl->gl_sbd; -struct inode *aspace = gl->gl_aspace; -struct address_space *mapping = gl->gl_aspace->i_mapping; - -gfs2_assert_withdraw (sdp, !atomic_read (&gl->gl_ail_count)); - -atomic_inc (&aspace->i_writecount); -truncate_inode_pages (mapping,0 ); -atomic_dec (&aspace->i_writecount); - -gfs2_assert_withdraw (sdp, !mapping->nrpages); -} - -/** * gfs2_meta_sync - Sync all buffers associated with a glock * @gl: The glock *
fs/gfs2/meta_io.h +0 -1
@@ -40,7 +40,6 @@ static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,struct inode *gfs2_aspace_get (struct gfs2_sbd *sdp);void gfs2_aspace_put (struct inode *aspace); -void gfs2_meta_inval (struct gfs2_glock *gl);void gfs2_meta_sync (struct gfs2_glock *gl);struct buffer_head *gfs2_meta_new (struct gfs2_glock *gl,u64 blkno);
fs/gfs2/ops_file.c +2 -1
@@ -355,7 +355,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)if (ret) goto out; -set_bit (GIF_SW_PAGED , &ip->i_flags); ret =gfs2_write_alloc_required (ip, pos,PAGE_CACHE_SIZE , &alloc_required);if (ret || !alloc_required) goto out_unlock;
@@ -396,6 +395,8 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page) goto out_unlock_page; } ret =gfs2_allocate_page_backing (page); +if (!ret) +set_bit (GIF_SW_PAGED , &ip->i_flags); out_unlock_page:unlock_page (page);
fs/gfs2/ops_fstype.c +3 -3
@@ -296,15 +296,15 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector)__free_page (page);return 0 ; } +/** * gfs2_read_sb - Read super block * @sdp: The GFS2 superblock -* @gl: the glock for the superblock (assumed to be held) * @silent: Don't print message if mount fails * */ -static int gfs2_read_sb (struct gfs2_sbd *sdp,struct gfs2_glock *gl,int silent) +static int gfs2_read_sb (struct gfs2_sbd *sdp,int silent) {u32 hash_blocks, ind_blocks, leaf_blocks;u32 tmp_blocks;
@@ -524,7 +524,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent)return ret; } - ret =gfs2_read_sb (sdp, sb_gh.gh_gl, silent); + ret =gfs2_read_sb (sdp, silent);if (ret) {fs_err (sdp,"can't read superblock: %d\n" , ret); goto out;
Signature · 1 line
1.6.0.3