GFS2: Pre-pull patch posting (merge window)
Hi,
This must be about the smallest merge window patch set ever for GFS2. It is probably also the first one without a single patch from me. That is down to a combination of factors, and I have some things in the works that are not quite ready yet, that I hope to put in next time around.
Returning to what is here this time... we have 3 patches which fix various warnings. Two are bug fixes (for quotas and also a rare recovery race condition). The final patch, from Ben Marzinski, is an important change in the freeze code which has been in progress for some time. This removes the need to take and drop the transaction lock for every single transaction, when the only time it was used, was at file system freeze time. Ben's patch integrates the freeze operation into the journal flush code as an alternative with lower overheads and also lands up resolving some difficult to fix races at the same time,
Steve.
PATCH 1/6 GFS2: quotas not being refreshed in gfs2_adjust_quota
From: Abhi Das <[email protected]>
Old values of user quota limits were being used and could allow users to exceed their allotted quotas. This patch refreshes the limits to the latest values so that quotas are enforced correctly.
Resolves: rhbz#1077463
fs/gfs2/quota.c +1 -0
@@ -778,6 +778,7 @@ get_a_page:i_size_write (inode, size); inode->i_mtime = inode->i_atime =CURRENT_TIME ;mark_inode_dirty (inode); +set_bit (QDF_REFRESH , &qd->qd_flags);return 0 ; unlock_out:
Signature · 1 line
1.8.3.1
PATCH 2/6 GFS2: lops.c: replace 0 by NULL for pointers
In reply to Steven WhitehouseFrom: Fabian Frederick <[email protected]>
Sparse warning: fs/gfs2/lops.c:78:29:
"warning: Using plain integer as NULL pointer"
fs/gfs2/lops.c +1 -1
@@ -75,7 +75,7 @@ static void maybe_release_space(struct gfs2_bufdata *bd)unsigned int index = bd->bd_bh->b_blocknr - gl->gl_name.ln_number;struct gfs2_bitmap *bi = rgd->rd_bits + index; -if (bi->bi_clone ==0 ) +if (bi->bi_clone ==NULL )return ;if (sdp->sd_args.ar_discard)gfs2_rgrp_send_discards (sdp, rgd->rd_data0, bd->bd_bh, bi,1 ,NULL );
Signature · 1 line
1.8.3.1
PATCH 3/6 GFS2: remove transaction glock
In reply to Steven WhitehouseFrom: Benjamin Marzinski <[email protected]>
GFS2 has a transaction glock, which must be grabbed for every transaction, whose purpose is to deal with freezing the filesystem. Aside from this involving a large amount of locking, it is very easy to make the current fsfreeze code hang on unfreezing.
This patch rewrites how gfs2 handles freezing the filesystem. The transaction glock is removed. In it's place is a freeze glock, which is cached (but not held) in a shared state by every node in the cluster when the filesystem is mounted. This lock only needs to be grabbed on freezing, and actions which need to be safe from freezing, like recovery.
When a node wants to freeze the filesystem, it grabs this glock exclusively. When the freeze glock state changes on the nodes (either from shared to unlocked, or shared to exclusive), the filesystem does a special log flush. gfs2_log_flush() does all the work for flushing out the and shutting down the incore log, and then it tries to grab the freeze glock in a shared state again. Since the filesystem is stuck in gfs2_log_flush, no new transaction can start, and nothing can be written to disk. Unfreezing the filesytem simply involes dropping the freeze glock, allowing gfs2_log_flush() to grab and then release the shared lock, so it is cached for next time.
However, in order for the unfreezing ioctl to occur, gfs2 needs to get a shared lock on the filesystem root directory inode to check permissions. If that glock has already been grabbed exclusively, fsfreeze will be unable to get the shared lock and unfreeze the filesystem.
In order to allow the unfreeze, this patch makes gfs2 grab a shared lock on the filesystem root directory during the freeze, and hold it until it unfreezes the filesystem. The functions which need to grab a shared lock in order to allow the unfreeze ioctl to be issued now use the lock grabbed by the freeze code instead.
The freeze and unfreeze code take care to make sure that this shared lock will not be dropped while another process is using it.
fs/gfs2/aops.c +1 -1
@@ -431,7 +431,7 @@ static int gfs2_jdata_writepages(struct address_space *mapping, ret =gfs2_write_cache_jdata (mapping, wbc);if (ret ==0 && wbc->sync_mode ==WB_SYNC_ALL ) { -gfs2_log_flush (sdp, ip->i_gl); +gfs2_log_flush (sdp, ip->i_gl,NORMAL_FLUSH ); ret =gfs2_write_cache_jdata (mapping, wbc); }return ret;
fs/gfs2/file.c +1 -1
@@ -256,7 +256,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) }if ((flags ^ new_flags) &GFS2_DIF_JDATA ) {if (flags &GFS2_DIF_JDATA ) -gfs2_log_flush (sdp, ip->i_gl); +gfs2_log_flush (sdp, ip->i_gl,NORMAL_FLUSH ); error =filemap_fdatawrite (inode->i_mapping);if (error) goto out;
fs/gfs2/glops.c +32 -19
126 lines not on this page · raw message
fs/gfs2/glops.h +1 -1
@@ -15,7 +15,7 @@extern const struct gfs2_glock_operations gfs2_meta_glops;extern const struct gfs2_glock_operations gfs2_inode_glops;extern const struct gfs2_glock_operations gfs2_rgrp_glops; -extern const struct gfs2_glock_operations gfs2_trans_glops; +extern const struct gfs2_glock_operations gfs2_freeze_glops;extern const struct gfs2_glock_operations gfs2_iopen_glops;extern const struct gfs2_glock_operations gfs2_flock_glops;extern const struct gfs2_glock_operations gfs2_nondisk_glops;
fs/gfs2/incore.h +8 -4
@@ -465,9 +465,7 @@ struct gfs2_trans {unsigned int tr_reserved; unsigned int tr_touched:1; unsigned int tr_attached:1; - -struct gfs2_holder tr_t_gh; - + unsigned int tr_alloced:1;unsigned int tr_num_buf_new;unsigned int tr_num_databuf_new;
@@ -682,7 +680,7 @@ struct gfs2_sbd {struct lm_lockstruct sd_lockstruct;struct gfs2_holder sd_live_gh;struct gfs2_glock *sd_rename_gl; -struct gfs2_glock *sd_trans_gl; +struct gfs2_glock *sd_freeze_gl;wait_queue_head_t sd_glock_wait;atomic_t sd_glock_disposal;struct completion sd_locking_init;
@@ -794,6 +792,12 @@ struct gfs2_sbd {/* For quiescing the filesystem */ struct gfs2_holder sd_freeze_gh; +struct gfs2_holder sd_freeze_root_gh; +struct gfs2_holder sd_thaw_gh; +atomic_t sd_log_freeze; +atomic_t sd_frozen_root; +wait_queue_head_t sd_frozen_root_wait; +wait_queue_head_t sd_log_frozen_wait;char sd_fsname[GFS2_FSNAME_LEN ];char sd_table_name[GFS2_FSNAME_LEN ];
fs/gfs2/inode.c +30 -10
@@ -1613,18 +1613,26 @@ int gfs2_permission(struct inode *inode, int mask) {struct gfs2_inode *ip;struct gfs2_holder i_gh; +struct gfs2_sbd *sdp =GFS2_SB (inode);int error;int unlock =0 ; +int frozen_root =0 ; ip =GFS2_I (inode);if (gfs2_glock_is_locked_by_me (ip->i_gl) ==NULL ) { -if (mask &MAY_NOT_BLOCK ) -return -ECHILD ; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); -if (error) -return error; - unlock =1 ; +if (unlikely (gfs2_glock_is_held_excl (sdp->sd_freeze_gl) && + inode == sdp->sd_root_dir->d_inode && +atomic_inc_not_zero (&sdp->sd_frozen_root))) + frozen_root =1 ; +else { +if (mask &MAY_NOT_BLOCK ) +return -ECHILD ; + error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); +if (error) +return error; + unlock =1 ; + } }if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode))
@@ -1633,6 +1641,8 @@ int gfs2_permission(struct inode *inode, int mask) error =generic_permission (inode, mask);if (unlock)gfs2_glock_dq_uninit (&i_gh); +else if (frozen_root &&atomic_dec_and_test (&sdp->sd_frozen_root)) +wake_up (&sdp->sd_frozen_root_wait);return error; }
@@ -1805,19 +1815,29 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,struct inode *inode = dentry->d_inode;struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_holder gh; +struct gfs2_sbd *sdp =GFS2_SB (inode);int error;int unlock =0 ; +int frozen_root =0 ;if (gfs2_glock_is_locked_by_me (ip->i_gl) ==NULL ) { - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &gh); -if (error) -return error; - unlock =1 ; +if (unlikely (gfs2_glock_is_held_excl (sdp->sd_freeze_gl) && + inode == sdp->sd_root_dir->d_inode && +atomic_inc_not_zero (&sdp->sd_frozen_root))) + frozen_root =1 ; +else { + error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &gh); +if (error) +return error; + unlock =1 ; + } }generic_fillattr (inode, stat);if (unlock)gfs2_glock_dq_uninit (&gh); +else if (frozen_root &&atomic_dec_and_test (&sdp->sd_frozen_root)) +wake_up (&sdp->sd_frozen_root_wait);return 0 ; }
fs/gfs2/log.c +63 -30
156 lines not on this page · raw message
fs/gfs2/log.h +9 -2
@@ -63,14 +63,21 @@ extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);extern unsigned int gfs2_struct2blk (struct gfs2_sbd *sdp,unsigned int nstruct,unsigned int ssize); +extern void gfs2_log_release (struct gfs2_sbd *sdp,unsigned int blks);extern int gfs2_log_reserve (struct gfs2_sbd *sdp,unsigned int blks); -extern void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl); +enum gfs2_flush_type { +NORMAL_FLUSH =0 , +SYNC_FLUSH , +SHUTDOWN_FLUSH , +FREEZE_FLUSH +}; +extern void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl, +enum gfs2_flush_type type);extern void gfs2_log_commit (struct gfs2_sbd *sdp,struct gfs2_trans *trans);extern void gfs2_remove_from_ail (struct gfs2_bufdata *bd);extern void gfs2_ail1_flush (struct gfs2_sbd *sdp,struct writeback_control *wbc);extern void gfs2_log_shutdown (struct gfs2_sbd *sdp); -extern void gfs2_meta_syncfs (struct gfs2_sbd *sdp);extern int gfs2_logd (void *data);extern void gfs2_add_revoke (struct gfs2_sbd *sdp,struct gfs2_bufdata *bd);extern void gfs2_write_revokes (struct gfs2_sbd *sdp);
fs/gfs2/ops_fstype.c +17 -5
@@ -129,6 +129,10 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)init_rwsem (&sdp->sd_log_flush_lock);atomic_set (&sdp->sd_log_in_flight,0 );init_waitqueue_head (&sdp->sd_log_flush_wait); +init_waitqueue_head (&sdp->sd_log_frozen_wait); +atomic_set (&sdp->sd_log_freeze,0 ); +atomic_set (&sdp->sd_frozen_root,0 ); +init_waitqueue_head (&sdp->sd_frozen_root_wait);return sdp; }
@@ -419,8 +423,8 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, goto fail_live; } - error =gfs2_glock_get (sdp,GFS2_TRANS_LOCK , &gfs2_trans_glops, -CREATE , &sdp->sd_trans_gl); + error =gfs2_glock_get (sdp,GFS2_FREEZE_LOCK , &gfs2_freeze_glops, +CREATE , &sdp->sd_freeze_gl);if (error) {fs_err (sdp,"can't create transaction glock: %d\n" , error); goto fail_rename;
@@ -429,7 +433,7 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,return 0 ; fail_trans: -gfs2_glock_put (sdp->sd_trans_gl); +gfs2_glock_put (sdp->sd_freeze_gl); fail_rename:gfs2_glock_put (sdp->sd_rename_gl); fail_live:
@@ -755,7 +759,15 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)set_bit (SDF_JOURNAL_CHECKED , &sdp->sd_flags);gfs2_glock_dq_uninit (&ji_gh); jindex =0 ; - +if (!sdp->sd_args.ar_spectator) { + error =gfs2_glock_nq_init (sdp->sd_freeze_gl,LM_ST_SHARED ,0 , + &sdp->sd_thaw_gh); +if (error) { +fs_err (sdp,"can't acquire freeze glock: %d\n" , error); + goto fail_jinode_gh; + } + } +gfs2_glock_dq_uninit (&sdp->sd_thaw_gh);return 0 ; fail_jinode_gh:
@@ -1380,7 +1392,7 @@ static void gfs2_kill_sb(struct super_block *sb)return ; } -gfs2_meta_syncfs (sdp); +gfs2_log_flush (sdp,NULL ,SYNC_FLUSH );dput (sdp->sd_root_dir);dput (sdp->sd_master_dir); sdp->sd_root_dir =NULL ;
fs/gfs2/quota.c +1 -1
@@ -880,7 +880,7 @@ out:gfs2_glock_dq_uninit (&ghs[qx]);mutex_unlock (&ip->i_inode.i_mutex);kfree (ghs); -gfs2_log_flush (ip->i_gl->gl_sbd, ip->i_gl); +gfs2_log_flush (ip->i_gl->gl_sbd, ip->i_gl,NORMAL_FLUSH );return error; }
fs/gfs2/recovery.c +11 -11
@@ -454,7 +454,7 @@ void gfs2_recover_func(struct work_struct *work)struct gfs2_inode *ip =GFS2_I (jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode);struct gfs2_log_header_host head; -struct gfs2_holder j_gh, ji_gh, t_gh; +struct gfs2_holder j_gh, ji_gh, thaw_gh;unsigned long t;int ro =0 ;unsigned int pass;
@@ -508,11 +508,11 @@ void gfs2_recover_func(struct work_struct *work) t = jiffies; -/* Acquire a shared hold on the transaction lock */ +/* Acquire a shared hold on the freeze lock */ - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED , -LM_FLAG_NOEXP |LM_FLAG_PRIORITY | -GL_NOCACHE , &t_gh); + error =gfs2_glock_nq_init (sdp->sd_freeze_gl,LM_ST_SHARED , +LM_FLAG_NOEXP |LM_FLAG_PRIORITY , + &thaw_gh);if (error) goto fail_gunlock_ji;
@@ -538,7 +538,7 @@ void gfs2_recover_func(struct work_struct *work)fs_warn (sdp,"jid=%u: Can't replay: read-only block " "device\n" , jd->jd_jid); error = -EROFS ; - goto fail_gunlock_tr; + goto fail_gunlock_thaw; }fs_info (sdp,"jid=%u: Replaying journal...\n" , jd->jd_jid);
@@ -549,14 +549,14 @@ void gfs2_recover_func(struct work_struct *work) head.lh_blkno, pass);lops_after_scan (jd, error, pass);if (error) - goto fail_gunlock_tr; + goto fail_gunlock_thaw; } error =clean_journal (jd, &head);if (error) - goto fail_gunlock_tr; + goto fail_gunlock_thaw; -gfs2_glock_dq_uninit (&t_gh); +gfs2_glock_dq_uninit (&thaw_gh); t =DIV_ROUND_UP (jiffies - t,HZ );fs_info (sdp,"jid=%u: Journal replayed in %lus\n" , jd->jd_jid, t);
@@ -572,8 +572,8 @@ void gfs2_recover_func(struct work_struct *work)fs_info (sdp,"jid=%u: Done\n" , jd->jd_jid); goto done; -fail_gunlock_tr: -gfs2_glock_dq_uninit (&t_gh); +fail_gunlock_thaw: +gfs2_glock_dq_uninit (&thaw_gh); fail_gunlock_ji:if (jlocked) {gfs2_glock_dq_uninit (&ji_gh);
fs/gfs2/rgrp.c +1 -1
@@ -2001,7 +2001,7 @@ next_rgrp: }/* Flushing the log may release space */ if (loops ==2 ) -gfs2_log_flush (sdp,NULL ); +gfs2_log_flush (sdp,NULL ,NORMAL_FLUSH ); }return -ENOSPC ;
fs/gfs2/super.c +43 -26
168 lines not on this page · raw message
fs/gfs2/sys.c +2 -2
@@ -240,8 +240,8 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t lenif (gltype >LM_TYPE_JOURNAL )return -EINVAL ; -if (gltype ==LM_TYPE_NONDISK && glnum ==GFS2_TRANS_LOCK ) - glops = &gfs2_trans_glops; +if (gltype ==LM_TYPE_NONDISK && glnum ==GFS2_FREEZE_LOCK ) + glops = &gfs2_freeze_glops;else glops = gfs2_glops_list[gltype];if (glops ==NULL )
fs/gfs2/trans.c +6 -38
87 lines not on this page · raw message
include/uapi/linux/gfs2_ondisk.h +1 -1
@@ -20,7 +20,7 @@#define GFS2_MOUNT_LOCK 0#define GFS2_LIVE_LOCK 1 -#define GFS2_TRANS_LOCK 2 +#define GFS2_FREEZE_LOCK 2#define GFS2_RENAME_LOCK 3#define GFS2_CONTROL_LOCK 4#define GFS2_MOUNTED_LOCK 5
Signature · 1 line
1.8.3.1
PATCH 4/6 GFS2: fs/gfs2/bmap.c: kernel-doc warning fixes
In reply to Steven WhitehouseFrom: Fabian Frederick <[email protected]>
Fix 2 typos and move one definition which was between function comments and function definition (yet another kernel-doc warning)
fs/gfs2/bmap.c +4 -4
@@ -707,7 +707,7 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi* @top: The first pointer in the buffer * @bottom: One more than the last pointer * @height: the height this buffer is at -* @data: a pointer to a struct strip_mine +* @sm: a pointer to a struct strip_mine * * Returns: errno */
@@ -992,6 +992,8 @@ unlock:return err; } +#define GFS2_JTRUNC_REVOKES 8192 +/** * gfs2_journaled_truncate - Wrapper for truncate_pagecache for jdata files * @inode: The inode being truncated
@@ -1003,8 +1005,6 @@ unlock:* if the number of pages being truncated gets too large. */ -#define GFS2_JTRUNC_REVOKES 8192 -static int gfs2_journaled_truncate (struct inode *inode,u64 oldsize,u64 newsize) {struct gfs2_sbd *sdp =GFS2_SB (inode);
@@ -1348,7 +1348,7 @@ void gfs2_free_journal_extents(struct gfs2_jdesc *jd)* gfs2_add_jextent - Add or merge a new extent to extent cache * @jd: The journal descriptor * @lblock: The logical block at start of new extent -* @pblock: The physical block at start of new extent +* @dblock: The physical block at start of new extent * @blocks: Size of extent in fs blocks * * Returns: 0 on success or -ENOMEM
Signature · 1 line
1.8.3.1
PATCH 5/6 GFS2: fs/gfs2/file.c: kernel-doc warning fixes
In reply to Steven WhitehouseFrom: Fabian Frederick <[email protected]>
Related function is not gfs2_set_flags but do_gfs2_set_flags
fs/gfs2/file.c +5 -5
@@ -203,9 +203,9 @@ void gfs2_set_inode_flags(struct inode *inode) GFS2_DIF_INHERIT_JDATA)/** -* gfs2_set_flags - set flags on an inode -* @inode: The inode -* @flags: The flags to set +* do_gfs2_set_flags - set flags on an inode +* @filp: file pointer +* @reqflags: The flags to set * @mask: Indicates which flags are valid * */
@@ -318,7 +318,7 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)/** * gfs2_size_hint - Give a hint to the size of a write request -* @file: The struct file +* @filep: The struct file * @offset: The file offset of the write * @size: The length of the write *
@@ -371,7 +371,7 @@ static int gfs2_allocate_page_backing(struct page *page)/** * gfs2_page_mkwrite - Make a shared, mmap()ed, page writable * @vma: The virtual memory area -* @page: The page which is about to become writable +* @vmf: The virtual memory fault containing the page to become writable * * When the page becomes writable, we need to ensure that we have * blocks allocated on disk to back that page.
Signature · 1 line
1.8.3.1
PATCH 6/6 GFS2: Prevent recovery before the local journal is set
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
This patch uses a completion to prevent dlm's recovery process from referencing and trying to recover a journal before a journal has been opened.
fs/gfs2/incore.h +2 -0
@@ -728,6 +728,8 @@ struct gfs2_sbd {struct gfs2_holder sd_sc_gh;struct gfs2_holder sd_qc_gh; +struct completion sd_journal_ready; +/* Daemon stuff */ struct task_struct *sd_logd_process;
fs/gfs2/ops_fstype.c +3 -0
@@ -94,6 +94,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)INIT_LIST_HEAD (&sdp->sd_jindex_list);spin_lock_init (&sdp->sd_jindex_spin);mutex_init (&sdp->sd_jindex_mutex); +init_completion (&sdp->sd_journal_ready);INIT_LIST_HEAD (&sdp->sd_quota_list);mutex_init (&sdp->sd_quota_mutex);
@@ -796,6 +797,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) goto fail_qinode; error =init_journal (sdp, undo); +complete_all (&sdp->sd_journal_ready);if (error) goto fail;
@@ -1212,6 +1214,7 @@ fail_sb: fail_locking:init_locking (sdp, &mount_gh,UNDO ); fail_lm: +complete_all (&sdp->sd_journal_ready);gfs2_gl_hash_clear (sdp);gfs2_lm_unmount (sdp); fail_debug:
fs/gfs2/sys.c +3 -0
@@ -407,6 +407,9 @@ int gfs2_recover_set(struct gfs2_sbd *sdp, unsigned jid)struct gfs2_jdesc *jd;int rv; +/* Wait for our primary journal to be initialized */ +wait_for_completion (&sdp->sd_journal_ready); +spin_lock (&sdp->sd_jindex_spin); rv = -EBUSY ;if (sdp->sd_jdesc->jd_jid == jid)
Signature · 1 line
1.8.3.1