GFS2: Pre-pull patch posting
Subsystems (2)
Hi,
As the merge window is more or less upon us, here is the content of the GFS2 -nmw tree. There is nothing too startling this time as the focus has very much been bug fixes and clean up.
We have a new mount option, commit= which does exactly the same thing as the ext3 equivalent option. We have a long term plan to make all the tunable parameters available as mount options and thus to be able to eventually drop the sysfs interface to these parameters.
Another long term plan is to get rid of the files named ops_somethingorother and to either merge them into other files, or rename them to not have the ops_ prefix. This patch series makes a start on that, and does all the easy ones. As a result some functions with only one caller are moved to the same file as their caller and made static.
The docs are also updated to reflect the fact that the lock_dlm interface module no longer exists and that interface is now built into GFS2.
Steve.
PATCH 1/24 GFS2: Update the rw flags
After Jens recent updates:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a1f242524c3c1f5d40f1c9c343427e34d1aadd6e
et al. this is a patch to bring gfs2 uptodate with the core code. Also I've managed to squash another call to ll_rw_block() along the way.
There is still one part of the GFS2 I/O paths which are not correctly annotated and that is due to the sharing of the writeback code between the data and metadata address spaces. I would like to change that too, but this patch is still worth doing on its own, I think.
fs/gfs2/log.c +3 -3
@@ -120,7 +120,7 @@ __acquires(&sdp->sd_log_lock)lock_buffer (bh);if (test_clear_buffer_dirty (bh)) { bh->b_end_io = end_buffer_write_sync; -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh); }else {unlock_buffer (bh);brelse (bh);
@@ -604,7 +604,7 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)if (test_bit (SDF_NOBARRIERS , &sdp->sd_flags)) goto skip_barrier;get_bh (bh); -submit_bh (WRITE_BARRIER | (1 <<BIO_RW_META ), bh); +submit_bh (WRITE_SYNC | (1 <<BIO_RW_BARRIER ) | (1 <<BIO_RW_META ), bh);wait_on_buffer (bh);if (buffer_eopnotsupp (bh)) {clear_buffer_eopnotsupp (bh);
@@ -664,7 +664,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)lock_buffer (bh);if (buffer_mapped (bh) &&test_clear_buffer_dirty (bh)) { bh->b_end_io = end_buffer_write_sync; -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh); }else {unlock_buffer (bh);brelse (bh);
fs/gfs2/lops.c +8 -6
@@ -13,6 +13,8 @@#include <linux/completion.h> #include <linux/buffer_head.h> #include <linux/gfs2_ondisk.h> +#include <linux/bio.h> +#include <linux/fs.h> #include "gfs2.h" #include "incore.h"
@@ -189,7 +191,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) }gfs2_log_unlock (sdp); -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh);gfs2_log_lock (sdp); n =0 ;
@@ -199,7 +201,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)gfs2_log_unlock (sdp);lock_buffer (bd2->bd_bh); bh =gfs2_log_fake_buf (sdp, bd2->bd_bh); -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh);gfs2_log_lock (sdp);if (++n >= num)break ;
@@ -341,7 +343,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) sdp->sd_log_num_revoke--;if (offset +sizeof (u64) > sdp->sd_sb.sb_bsize) { -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh); bh =gfs2_log_get_buf (sdp); mh = (struct gfs2_meta_header *)bh->b_data;
@@ -358,7 +360,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) }gfs2_assert_withdraw (sdp, !sdp->sd_log_num_revoke); -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh); } static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
@@ -560,7 +562,7 @@ static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh, ptr =bh_log_ptr (bh);get_bh (bh); -submit_bh (WRITE , bh); +submit_bh (WRITE_SYNC_PLUG , bh);gfs2_log_lock (sdp);while (!list_empty (list)) { bd = list_entry(list->next, struct gfs2_bufdata, bd_le.le_list);
@@ -586,7 +588,7 @@ static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh, }else { bh1 =gfs2_log_fake_buf (sdp, bd->bd_bh); } -submit_bh (WRITE , bh1); +submit_bh (WRITE_SYNC_PLUG , bh1);gfs2_log_lock (sdp); ptr +=2 ; }
fs/gfs2/meta_io.c +27 -11
@@ -201,16 +201,32 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)int gfs2_meta_read (struct gfs2_glock *gl,u64 blkno,int flags,struct buffer_head **bhp) { - *bhp =gfs2_getbuf (gl, blkno,CREATE ); -if (!buffer_uptodate (*bhp)) { -ll_rw_block (READ_META ,1 , bhp); -if (flags &DIO_WAIT ) { -int error =gfs2_meta_wait (gl->gl_sbd, *bhp); -if (error) { -brelse (*bhp); -return error; - } - } +struct gfs2_sbd *sdp = gl->gl_sbd; +struct buffer_head *bh; + +if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags))) +return -EIO ; + + *bhp = bh =gfs2_getbuf (gl, blkno,CREATE ); + +lock_buffer (bh); +if (buffer_uptodate (bh)) { +unlock_buffer (bh); +return 0 ; + } + bh->b_end_io = end_buffer_read_sync; +get_bh (bh); +submit_bh (READ_SYNC | (1 <<BIO_RW_META ), bh); +if (!(flags &DIO_WAIT )) +return 0 ; + +wait_on_buffer (bh); +if (unlikely (!buffer_uptodate (bh))) { +struct gfs2_trans *tr = current->journal_info; +if (tr && tr->tr_touched) +gfs2_io_error_bh (sdp, bh); +brelse (bh); +return -EIO ; }return 0 ;
@@ -404,7 +420,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)if (buffer_uptodate (first_bh)) goto out;if (!buffer_locked (first_bh)) -ll_rw_block (READ_META ,1 , &first_bh); +ll_rw_block (READ_SYNC | (1 <<BIO_RW_META ),1 , &first_bh); dblock++; extlen--;
Signature · 1 line
1.6.0.6
PATCH 2/24 GFS2: Optimise writepage for metadata
This adds a GFS2 specific writepage for metadata, rather than continuing to use the VFS function. As a result we now tag all our metadata I/O with the correct flag so that blktraces will now be less confusing.
Also, the generic function was checking for a number of corner cases which cannot happen on the metadata address spaces so that this should be faster too.
fs/gfs2/meta_io.c +57 -9
@@ -33,17 +33,65 @@#include "util.h" #include "ops_address.h" -static int aspace_get_block (struct inode *inode,sector_t lblock, -struct buffer_head *bh_result,int create) +static int gfs2_aspace_writepage (struct page *page,struct writeback_control *wbc) { -gfs2_assert_warn (inode->i_sb->s_fs_info,0 ); -return -EOPNOTSUPP ; -} +int err; +struct buffer_head *bh, *head; +int nr_underway =0 ; +int write_op = (1 <<BIO_RW_META ) | ((wbc->sync_mode ==WB_SYNC_ALL ? +WRITE_SYNC_PLUG :WRITE )); + +BUG_ON (!PageLocked (page)); +BUG_ON (!page_has_buffers (page)); + + head =page_buffers (page); + bh = head; + +do { +if (!buffer_mapped (bh)) +continue ; +/* +* If it's a fully non-blocking write attempt and we cannot +* lock the buffer then redirty the page. Note that this can +* potentially cause a busy-wait loop from pdflush and kswapd +* activity, but those code paths have their own higher-level +* throttling. +*/ +if (wbc->sync_mode !=WB_SYNC_NONE || !wbc->nonblocking) { +lock_buffer (bh); + }else if (!trylock_buffer (bh)) { +redirty_page_for_writepage (wbc, page); +continue ; + } +if (test_clear_buffer_dirty (bh)) { +mark_buffer_async_write (bh); + }else { +unlock_buffer (bh); + } + }while ((bh = bh->b_this_page) != head); + +/* +* The page and its buffers are protected by PageWriteback(), so we can +* drop the bh refcounts early. +*/ +BUG_ON (PageWriteback (page)); +set_page_writeback (page); + +do { +struct buffer_head *next = bh->b_this_page; +if (buffer_async_write (bh)) { +submit_bh (write_op, bh); + nr_underway++; + } + bh = next; + }while (bh != head); +unlock_page (page); -static int gfs2_aspace_writepage (struct page *page, -struct writeback_control *wbc) -{ -return block_write_full_page (page, aspace_get_block, wbc); + err =0 ; +if (nr_underway ==0 ) +end_page_writeback (page); + +return err; }static const struct address_space_operations aspace_aops = {
Signature · 1 line
1.6.0.6
PATCH 3/24 GFS2: Something nonlinear this way comes!
For some reason GFS2 has been missing support for non-linear mappings. This patch fixes that, and also avoids taking any locks for mmap in the O_NOATIME case. In fact we don't actually need to take the lock here at all - just doing file_accessed() would be enough, but we have to take the lock eventually and this helps it hit disk (and thus be seen by other nodes) faster.
fs/gfs2/ops_file.c +16 -13
@@ -425,33 +425,36 @@ static struct vm_operations_struct gfs2_vm_ops = { .page_mkwrite = gfs2_page_mkwrite, }; -/** * gfs2_mmap - * @file: The file to map * @vma: The VMA which described the mapping * -* Returns: 0 or error code +* There is no need to get a lock here unless we should be updating +* atime. We ignore any locking errors since the only consequence is +* a missed atime update (which will just be deferred until later). +* +* Returns: 0 */ static int gfs2_mmap (struct file *file,struct vm_area_struct *vma) {struct gfs2_inode *ip =GFS2_I (file->f_mapping->host); -struct gfs2_holder i_gh; -int error; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,0 , &i_gh); - error =gfs2_glock_nq (&i_gh); -if (error) { -gfs2_holder_uninit (&i_gh); -return error; - } +if (!(file->f_flags &O_NOATIME )) { +struct gfs2_holder i_gh; +int error; +gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq (&i_gh); +file_accessed (file); +if (error ==0 ) +gfs2_glock_dq_uninit (&i_gh); + } vma->vm_ops = &gfs2_vm_ops; + vma->vm_flags |=VM_CAN_NONLINEAR ; -gfs2_glock_dq_uninit (&i_gh); - -return error; +return 0 ; }/**
Signature · 1 line
1.6.0.6
PATCH 4/24 GFS2: Fix timestamps on write
From: Abhijith Das <[email protected]>
This patch copies the timestamps from the vfs inode into gfs2 and syncs it to the disk inode during writes.
fs/gfs2/ops_address.c +10 -10
@@ -781,10 +781,12 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,unlock_page (page);page_cache_release (page); -if (inode->i_size < to) { -i_size_write (inode, to); - ip->i_disksize = inode->i_size; - di->di_size =cpu_to_be64 (inode->i_size); +if (copied) { +if (inode->i_size < to) { +i_size_write (inode, to); + ip->i_disksize = inode->i_size; + } +gfs2_dinode_out (ip, di);mark_inode_dirty (inode); }
@@ -824,7 +826,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,struct gfs2_sbd *sdp =GFS2_SB (inode);struct buffer_head *dibh;struct gfs2_alloc *al = ip->i_alloc; -struct gfs2_dinode *di;unsigned int from = pos & (PAGE_CACHE_SIZE -1 );unsigned int to = from + len;int ret;
@@ -847,11 +848,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,gfs2_page_add_databufs (ip, page, from, to); ret =generic_write_end (file, mapping, pos, len, copied, page, fsdata); - -if (likely (ret >=0 ) && (inode->i_size > ip->i_disksize)) { - di = (struct gfs2_dinode *)dibh->b_data; - ip->i_disksize = inode->i_size; - di->di_size =cpu_to_be64 (inode->i_size); +if (ret >0 ) { +if (inode->i_size > ip->i_disksize) + ip->i_disksize = inode->i_size; +gfs2_dinode_out (ip, dibh->b_data);mark_inode_dirty (inode); }
Signature · 1 line
1.6.0.6
PATCH 5/24 GFS2: Move journal live test at transaction start
There seems little point grabbing the transaction glock only to have to release it again if the journal isn't live. This moves the test earlier to avoid grabbing the lock when we don't need it in the first place.
fs/gfs2/trans.c +3 -6
@@ -33,6 +33,9 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,BUG_ON (current->journal_info);BUG_ON (blocks ==0 && revokes ==0 ); +if (!test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) +return -EROFS ; + tr =kzalloc (sizeof (struct gfs2_trans ),GFP_NOFS );if (!tr)return -ENOMEM ;
@@ -54,12 +57,6 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,if (error) goto fail_holder_uninit; -if (!test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) { - tr->tr_t_gh.gh_flags |=GL_NOCACHE ; - error = -EROFS ; - goto fail_gunlock; - } - error =gfs2_log_reserve (sdp, tr->tr_reserved);if (error) goto fail_gunlock;
Signature · 1 line
1.6.0.6
PATCH 6/24 GFS2: Add commit= mount option
It has always been possible to adjust the gfs2 log commit interval, but only from the sysfs interface. This adds a mount option, commit=<nn>, which will be familar to ext3 users.
The sysfs interface continues to be available as well, although this might be removed in the future.
Also this patch cleans up some duplicated structures in the GFS2 sysfs code.
fs/gfs2/incore.h +1 -0
@@ -418,6 +418,7 @@ struct gfs2_args { unsigned int ar_data:2; /* ordered/writeback */ unsigned int ar_meta:1; /* mount metafs */ unsigned int ar_discard:1; /* discard requests */ +int ar_commit;/* Commit interval */ };struct gfs2_tune {
fs/gfs2/mount.c +10 -0
@@ -45,6 +45,7 @@ enum { Opt_meta, Opt_discard, Opt_nodiscard, + Opt_commit, Opt_err, };
@@ -73,6 +74,7 @@ static const match_table_t tokens = { {Opt_meta, "meta"}, {Opt_discard, "discard"}, {Opt_nodiscard, "nodiscard"}, + {Opt_commit, "commit=%d"}, {Opt_err, NULL} };
@@ -89,6 +91,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)char *o;int token;substring_t tmp[MAX_OPT_ARGS ]; +int rv;/* Split the options into tokens with the "," character and process them */
@@ -173,6 +176,13 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)case Opt_nodiscard: args->ar_discard =0 ;break ; +case Opt_commit: + rv =match_int (&tmp[0 ], &args->ar_commit); +if (rv || args->ar_commit <=0 ) { +fs_info (sdp,"commit mount option requires a positive numeric argument\n" ); +return rv ? rv : -EINVAL ; + } +break ;case Opt_err:default :fs_info (sdp,"invalid mount option: %s\n" , o);
fs/gfs2/ops_fstype.c +3 -1
@@ -55,7 +55,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt)spin_lock_init (>->gt_spin); gt->gt_incore_log_blocks =1024 ; - gt->gt_log_flush_secs =60 ; gt->gt_recoverd_secs =60 ; gt->gt_logd_secs =1 ; gt->gt_quota_simul_sync =64 ;
@@ -1165,6 +1164,7 @@ static int fill_super(struct super_block *sb, void *data, int silent) sdp->sd_args.ar_quota =GFS2_QUOTA_DEFAULT ; sdp->sd_args.ar_data =GFS2_DATA_DEFAULT ; + sdp->sd_args.ar_commit =60 ; error =gfs2_mount_args (sdp, &sdp->sd_args, data);if (error) {
@@ -1191,6 +1191,8 @@ static int fill_super(struct super_block *sb, void *data, int silent)GFS2_BASIC_BLOCK_SHIFT ; sdp->sd_fsb2bb =1 << sdp->sd_fsb2bb_shift; + sdp->sd_tune.gt_log_flush_secs = sdp->sd_args.ar_commit; + error =init_names (sdp, silent);if (error) goto fail;
fs/gfs2/ops_super.c +12 -1
@@ -436,8 +436,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) {struct gfs2_sbd *sdp = sb->s_fs_info;struct gfs2_args args = sdp->sd_args;/* Default to current settings */ +struct gfs2_tune *gt = &sdp->sd_tune;int error; +spin_lock (>->gt_spin); + args.ar_commit = gt->gt_log_flush_secs; +spin_unlock (>->gt_spin); error =gfs2_mount_args (sdp, &args, data);if (error)return error;
@@ -473,6 +477,10 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) sb->s_flags |=MS_POSIXACL ; else sb->s_flags &= ~MS_POSIXACL; +spin_lock (>->gt_spin); + gt->gt_log_flush_secs = args.ar_commit; +spin_unlock (>->gt_spin); +return 0 ; }
@@ -550,6 +558,7 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) {struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;struct gfs2_args *args = &sdp->sd_args; +int lfsecs;if (is_ancestor (mnt->mnt_root, sdp->sd_master_dir))seq_printf (s,",meta" );
@@ -610,7 +619,9 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) }if (args->ar_discard)seq_printf (s,",discard" ); - + lfsecs = sdp->sd_tune.gt_log_flush_secs; +if (lfsecs !=60 ) +seq_printf (s,",commit=%d" , lfsecs);return 0 ; }
fs/gfs2/sys.c +34 -58
149 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 7/24 GFS2: Remove a couple of unused sysfs entries
These two tunables are pointless and would never need to be changed anyway. There is also a race between them and umount as the deamons which they refer to might have gone away. The easiest way to fix the race is to remove the interface.
fs/gfs2/sys.c +0 -13
@@ -530,15 +530,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ } \ TUNE_ATTR_2(name, name##_store) -#define TUNE_ATTR_DAEMON (name, process) \ -static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ -{ \ - ssize_t r = tune_set(sdp, &sdp->sd_tune.gt_##name, 1, buf, len); \ - wake_up_process(sdp->sd_##process); \ - return r; \ -} \ -TUNE_ATTR_2(name, name##_store) -TUNE_ATTR (incore_log_blocks,0 );TUNE_ATTR (log_flush_secs,0 );TUNE_ATTR (quota_warn_period,0 );
@@ -550,8 +541,6 @@ TUNE_ATTR(new_files_jdata, 0);TUNE_ATTR (quota_simul_sync,1 );TUNE_ATTR (stall_secs,1 );TUNE_ATTR (statfs_quantum,1 ); -TUNE_ATTR_DAEMON (recoverd_secs, recoverd_process); -TUNE_ATTR_DAEMON (logd_secs, logd_process);TUNE_ATTR_3 (quota_scale, quota_scale_show, quota_scale_store);static struct attribute *tune_attrs[] = {
@@ -565,8 +554,6 @@ static struct attribute *tune_attrs[] = { &tune_attr_quota_simul_sync.attr, &tune_attr_stall_secs.attr, &tune_attr_statfs_quantum.attr, - &tune_attr_recoverd_secs.attr, - &tune_attr_logd_secs.attr, &tune_attr_quota_scale.attr, &tune_attr_new_files_jdata.attr, NULL,
Signature · 1 line
1.6.0.6
PATCH 8/24 GFS2: Umount recovery race fix
This patch fixes a race condition where we can receive recovery requests part way through processing a umount. This was causing problems since the recovery thread had already gone away.
Looking in more detail at the recovery code, it was really trying to implement a slight variation on a work queue, and that happens to align nicely with the recently introduced slow-work subsystem. As a result I've updated the code to use slow-work, rather than its own home grown variety of work queue.
When using the wait_on_bit() function, I noticed that the wait function that was supplied as an argument was appearing in the WCHAN field, so I've updated the function names in order to produce more meaningful output.
fs/gfs2/Kconfig +1 -0
@@ -7,6 +7,7 @@ config GFS2_FS select IP_SCTP if DLM_SCTP select FS_POSIX_ACL select CRC32 + select SLOW_WORK help A cluster filesystem.
fs/gfs2/glock.c +18 -3
@@ -796,22 +796,37 @@ void gfs2_holder_uninit(struct gfs2_holder *gh) gh->gh_ip =0 ; } -static int just_schedule (void *word) +/** +* gfs2_glock_holder_wait +* @word: unused +* +* This function and gfs2_glock_demote_wait both show up in the WCHAN +* field. Thus I've separated these otherwise identical functions in +* order to be more informative to the user. +*/ + +static int gfs2_glock_holder_wait (void *word) {schedule ();return 0 ; } +static int gfs2_glock_demote_wait (void *word) +{ +schedule (); +return 0 ; +} +static void wait_on_holder (struct gfs2_holder *gh) {might_sleep (); -wait_on_bit (&gh->gh_iflags,HIF_WAIT , just_schedule,TASK_UNINTERRUPTIBLE ); +wait_on_bit (&gh->gh_iflags,HIF_WAIT , gfs2_glock_holder_wait,TASK_UNINTERRUPTIBLE ); }static void wait_on_demote (struct gfs2_glock *gl) {might_sleep (); -wait_on_bit (&gl->gl_flags,GLF_DEMOTE , just_schedule,TASK_UNINTERRUPTIBLE ); +wait_on_bit (&gl->gl_flags,GLF_DEMOTE , gfs2_glock_demote_wait,TASK_UNINTERRUPTIBLE ); }/**
fs/gfs2/incore.h +5 -9
@@ -12,6 +12,7 @@#include <linux/fs.h> #include <linux/workqueue.h> +#include <linux/slow-work.h> #include <linux/dlm.h> #include <linux/buffer_head.h>
@@ -376,11 +377,11 @@ struct gfs2_journal_extent {struct gfs2_jdesc {struct list_head jd_list;struct list_head extent_list; - +struct slow_work jd_work;struct inode *jd_inode; +unsigned long jd_flags; +#define JDF_RECOVERY 1unsigned int jd_jid; -int jd_dirty; -unsigned int jd_blocks; };
@@ -390,9 +391,6 @@ struct gfs2_statfs_change_host {s64 sc_dinodes; }; -#define GFS2_GLOCKD_DEFAULT 1 -#define GFS2_GLOCKD_MAX 16 -#define GFS2_QUOTA_DEFAULT GFS2_QUOTA_OFF#define GFS2_QUOTA_OFF 0#define GFS2_QUOTA_ACCOUNT 1
@@ -427,7 +425,6 @@ struct gfs2_tune {unsigned int gt_incore_log_blocks;unsigned int gt_log_flush_secs; -unsigned int gt_recoverd_secs;unsigned int gt_logd_secs;unsigned int gt_quota_simul_sync;/* Max quotavals to sync at once */
@@ -448,6 +445,7 @@ enum {SDF_JOURNAL_LIVE =1 ,SDF_SHUTDOWN =2 ,SDF_NOBARRIERS =3 , + SDF_NORECOVERY = 4, };#define GFS2_FSNAME_LEN 256
@@ -494,7 +492,6 @@ struct lm_lockstruct {unsigned long ls_flags;dlm_lockspace_t *ls_dlm; -int ls_recover_jid;int ls_recover_jid_done;int ls_recover_jid_status; };
@@ -583,7 +580,6 @@ struct gfs2_sbd {/* Daemon stuff */ -struct task_struct *sd_recoverd_process;struct task_struct *sd_logd_process;struct task_struct *sd_quotad_process;
fs/gfs2/main.c +8 -0
@@ -15,6 +15,7 @@#include <linux/init.h> #include <linux/gfs2_ondisk.h> #include <asm/atomic.h> +#include <linux/slow-work.h> #include "gfs2.h" #include "incore.h"
@@ -113,12 +114,18 @@ static int __init init_gfs2_fs(void)if (error) goto fail_unregister; + error =slow_work_register_user (); +if (error) + goto fail_slow; +gfs2_register_debugfs ();printk ("GFS2 (built %s %s) installed\n" , __DATE__, __TIME__);return 0 ; +fail_slow: +unregister_filesystem (&gfs2meta_fs_type); fail_unregister:unregister_filesystem (&gfs2_fs_type); fail:
@@ -156,6 +163,7 @@ static void __exit exit_gfs2_fs(void)gfs2_unregister_debugfs ();unregister_filesystem (&gfs2_fs_type);unregister_filesystem (&gfs2meta_fs_type); +slow_work_unregister_user ();kmem_cache_destroy (gfs2_quotad_cachep);kmem_cache_destroy (gfs2_rgrpd_cachep);
fs/gfs2/ops_fstype.c +6 -14
@@ -17,6 +17,7 @@#include <linux/namei.h> #include <linux/mount.h> #include <linux/gfs2_ondisk.h> +#include <linux/slow-work.h> #include "gfs2.h" #include "incore.h"
@@ -55,7 +56,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt)spin_lock_init (>->gt_spin); gt->gt_incore_log_blocks =1024 ; - gt->gt_recoverd_secs =60 ; gt->gt_logd_secs =1 ; gt->gt_quota_simul_sync =64 ; gt->gt_quota_warn_period =10 ;
@@ -675,6 +675,7 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)break ;INIT_LIST_HEAD (&jd->extent_list); +slow_work_init (&jd->jd_work, &gfs2_recover_ops); jd->jd_inode =gfs2_lookupi (sdp->sd_jindex, &name,1 );if (!jd->jd_inode ||IS_ERR (jd->jd_inode)) {if (!jd->jd_inode)
@@ -700,14 +701,13 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) {struct inode *master = sdp->sd_master_dir->d_inode;struct gfs2_holder ji_gh; -struct task_struct *p;struct gfs2_inode *ip;int jindex =1 ;int error =0 ;if (undo) { jindex =0 ; - goto fail_recoverd; + goto fail_jinode_gh; } sdp->sd_jindex =gfs2_lookup_simple (master,"jindex" );
@@ -800,18 +800,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)gfs2_glock_dq_uninit (&ji_gh); jindex =0 ; - p =kthread_run (gfs2_recoverd, sdp,"gfs2_recoverd" ); - error =IS_ERR (p); -if (error) { -fs_err (sdp,"can't start recoverd thread: %d\n" , error); - goto fail_jinode_gh; - } - sdp->sd_recoverd_process = p; -return 0 ; -fail_recoverd: -kthread_stop (sdp->sd_recoverd_process); fail_jinode_gh:if (!sdp->sd_args.ar_spectator)gfs2_glock_dq_uninit (&sdp->sd_jinode_gh);
@@ -1172,8 +1162,10 @@ static int fill_super(struct super_block *sb, void *data, int silent) goto fail; } -if (sdp->sd_args.ar_spectator) +if (sdp->sd_args.ar_spectator) { sb->s_flags |=MS_RDONLY ; +set_bit (SDF_NORECOVERY , &sdp->sd_flags); + }if (sdp->sd_args.ar_posix_acl) sb->s_flags |=MS_POSIXACL ;
fs/gfs2/ops_super.c +24 -1
@@ -121,6 +121,12 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp)return error; } +static int gfs2_umount_recovery_wait (void *word) +{ +schedule (); +return 0 ; +} +/** * gfs2_put_super - Unmount the filesystem * @sb: The VFS superblock
@@ -131,6 +137,7 @@ static void gfs2_put_super(struct super_block *sb) {struct gfs2_sbd *sdp = sb->s_fs_info;int error; +struct gfs2_jdesc *jd;/* Unfreeze the filesystem, if we need to */
@@ -139,9 +146,25 @@ static void gfs2_put_super(struct super_block *sb)gfs2_glock_dq_uninit (&sdp->sd_freeze_gh);mutex_unlock (&sdp->sd_freeze_lock); +/* No more recovery requests */ +set_bit (SDF_NORECOVERY , &sdp->sd_flags); +smp_mb (); + +/* Wait on outstanding recovery */ +restart: +spin_lock (&sdp->sd_jindex_spin); +list_for_each_entry (jd, &sdp->sd_jindex_list, jd_list) { +if (!test_bit (JDF_RECOVERY , &jd->jd_flags)) +continue ; +spin_unlock (&sdp->sd_jindex_spin); +wait_on_bit (&jd->jd_flags,JDF_RECOVERY , + gfs2_umount_recovery_wait,TASK_UNINTERRUPTIBLE ); + goto restart; + } +spin_unlock (&sdp->sd_jindex_spin); +kthread_stop (sdp->sd_quotad_process);kthread_stop (sdp->sd_logd_process); -kthread_stop (sdp->sd_recoverd_process);if (!(sb->s_flags &MS_RDONLY )) { error =gfs2_make_fs_ro (sdp);
fs/gfs2/recovery.c +33 -69
136 lines not on this page · raw message
fs/gfs2/recovery.h +1 -1
@@ -28,7 +28,7 @@ extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);extern int gfs2_find_jhead (struct gfs2_jdesc *jd,struct gfs2_log_header_host *head);extern int gfs2_recover_journal (struct gfs2_jdesc *gfs2_jd); -extern int gfs2_recoverd (void *data); +extern struct slow_work_ops gfs2_recover_ops;#endif /* __RECOVERY_DOT_H__ */
fs/gfs2/sys.c +26 -27
75 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 9/24 GFS2: Update docs
Update a few things which were out of date, and fix a typo.
Documentation/filesystems/gfs2-glocks.txt +1 -1
@@ -60,7 +60,7 @@ go_lock | Called for the first local holder of a lock go_unlock | Called on the final local unlock of a lock go_dump | Called to print content of object for debugfs file, or on | error to dump glock to the log. -go_type; | The type of the glock, LM_TYPE_..... +go_type | The type of the glock, LM_TYPE_..... go_min_hold_time | The minimum hold time The minimum hold time for each lock is the time after a remote lock
Documentation/filesystems/gfs2.txt +11 -8
@@ -11,18 +11,15 @@ their I/O so file system consistency is maintained. One of the nifty features of GFS is perfect consistency -- changes made to the file system on one machine show up immediately on all other machines in the cluster. -GFS uses interchangable inter-node locking mechanisms. Different lock -modules can plug into GFS and each file system selects the appropriate -lock module at mount time. Lock modules include: +GFS uses interchangable inter-node locking mechanisms, the currently +supported mechanisms are: lock_nolock -- allows gfs to be used as a local file system lock_dlm -- uses a distributed lock manager (dlm) for inter-node locking The dlm is found at linux/fs/dlm/ -In addition to interfacing with an external locking manager, a gfs lock -module is responsible for interacting with external cluster management -systems. Lock_dlm depends on user space cluster management systems found +Lock_dlm depends on user space cluster management systems found at the URL above. To use gfs as a local file system, no external clustering systems are
@@ -31,13 +28,19 @@ needed, simply: $ mkfs -t gfs2 -p lock_nolock -j 1 /dev/block_device $ mount -t gfs2 /dev/block_device /dir -GFS2 is not on-disk compatible with previous versions of GFS. +If you are using Fedora, you need to install the gfs2-utils package +and, for lock_dlm, you will also need to install the cman package +and write a cluster.conf as per the documentation. + +GFS2 is not on-disk compatible with previous versions of GFS, but it +is pretty close. The following man pages can be found at the URL above: - gfs2_fsck to repair a filesystem + fsck.gfs2 to repair a filesystem gfs2_grow to expand a filesystem online gfs2_jadd to add journals to a filesystem online gfs2_tool to manipulate, examine and tune a filesystem gfs2_quota to examine and change quota values in a filesystem + gfs2_convert to convert a gfs filesystem to gfs2 in-place mount.gfs2 to help mount(8) mount a filesystem mkfs.gfs2 to make a filesystem
Signature · 1 line
1.6.0.6
PATCH 10/24 GFS2: Don't warn when delete inode fails on ro filesystem
If the filesystem is read-only, then we expect that delete inode will fail, so there is no need to warn about it.
fs/gfs2/ops_super.c +1 -1
@@ -714,7 +714,7 @@ out_unlock:gfs2_glock_dq (&ip->i_iopen_gh);gfs2_holder_uninit (&ip->i_iopen_gh);gfs2_glock_dq_uninit (&gh); -if (error && error !=GLR_TRYFAILED ) +if (error && error !=GLR_TRYFAILED && error != -EROFS )fs_warn (sdp,"gfs2_delete_inode: %d\n" , error); out:truncate_inode_pages (&inode->i_data,0 );
Signature · 1 line
1.6.0.6
PATCH 11/24 GFS2: Improve resource group error handling
This patch improves the error handling in the case where we discover that the summary information in the resource group doesn't match the bitmap information while in the process of allocating blocks. Originally this resulted in a kernel bug, but this patch changes that so that we return -EIO and print some messages explaining what went wrong, and how to fix it.
We also remember locally not to try and allocate from the same rgrp again, so that a subsequent allocation in a different rgrp should succeed.
fs/gfs2/bmap.c +7 -2
@@ -136,7 +136,9 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)and write it out to disk */ unsigned int n =1 ; - block =gfs2_alloc_block (ip, &n); + error =gfs2_alloc_block (ip, &block, &n); +if (error) + goto out_brelse;if (isdir) {gfs2_trans_add_unrevoke (GFS2_SB (&ip->i_inode), block,1 ); error =gfs2_dir_get_new_buffer (ip, block, &bh);
@@ -476,8 +478,11 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, blks = dblks + iblks; i = sheight; do { + int error; n = blks - alloced; - bn = gfs2_alloc_block(ip, &n); + error = gfs2_alloc_block(ip, &bn, &n); + if (error) + return error; alloced += n; if (state != ALLOC_DATA || gfs2_is_jdata(ip)) gfs2_trans_add_unrevoke(sdp, bn, n);
fs/gfs2/dir.c +9 -2
@@ -803,13 +803,20 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, {struct gfs2_inode *ip =GFS2_I (inode);unsigned int n =1 ; -u64 bn =gfs2_alloc_block (ip, &n); -struct buffer_head *bh =gfs2_meta_new (ip->i_gl, bn); +u64 bn; +int error; +struct buffer_head *bh;struct gfs2_leaf *leaf;struct gfs2_dirent *dent;struct qstr name = { .name ="" , .len =0 , .hash =0 }; + + error =gfs2_alloc_block (ip, &bn, &n); +if (error) +return NULL ; + bh =gfs2_meta_new (ip->i_gl, bn);if (!bh)return NULL ; +gfs2_trans_add_unrevoke (GFS2_SB (inode), bn,1 );gfs2_trans_add_bh (ip->i_gl, bh,1 );gfs2_metatype_set (bh,GFS2_METATYPE_LF ,GFS2_FORMAT_LF );
fs/gfs2/eattr.c +11 -3
@@ -582,8 +582,11 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)struct gfs2_ea_header *ea;unsigned int n =1 ;u64 block; +int error; - block =gfs2_alloc_block (ip, &n); + error =gfs2_alloc_block (ip, &block, &n); +if (error) +return error;gfs2_trans_add_unrevoke (sdp, block,1 ); *bhp =gfs2_meta_new (ip->i_gl, block);gfs2_trans_add_bh (ip->i_gl, *bhp,1 );
@@ -617,6 +620,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, struct gfs2_ea_request *er) {struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); +int error; ea->ea_data_len =cpu_to_be32 (er->er_data_len); ea->ea_name_len = er->er_name_len;
@@ -642,7 +646,9 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,int mh_size =sizeof (struct gfs2_meta_header );unsigned int n =1 ; - block =gfs2_alloc_block (ip, &n); + error =gfs2_alloc_block (ip, &block, &n); +if (error) +return error;gfs2_trans_add_unrevoke (sdp, block,1 ); bh =gfs2_meta_new (ip->i_gl, block);gfs2_trans_add_bh (ip->i_gl, bh,1 );
@@ -963,7 +969,9 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, }else {u64 blk;unsigned int n =1 ; - blk =gfs2_alloc_block (ip, &n); + error =gfs2_alloc_block (ip, &blk, &n); +if (error) +return error;gfs2_trans_add_unrevoke (sdp, blk,1 ); indbh =gfs2_meta_new (ip->i_gl, blk);gfs2_trans_add_bh (ip->i_gl, indbh,1 );
fs/gfs2/glops.c +1 -19
@@ -310,24 +310,6 @@ static void rgrp_go_unlock(struct gfs2_holder *gh) }/** -* rgrp_go_dump - print out an rgrp -* @seq: The iterator -* @gl: The glock in question -* -*/ - -static int rgrp_go_dump (struct seq_file *seq,const struct gfs2_glock *gl) -{ -const struct gfs2_rgrpd *rgd = gl->gl_object; -if (rgd ==NULL ) -return 0 ; -gfs2_print_dbg (seq," R: n:%llu f:%02x b:%u/%u i:%u\n" , - (unsigned long long )rgd->rd_addr, rgd->rd_flags, - rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes); -return 0 ; -} - -/** * trans_go_sync - promote/demote the transaction glock * @gl: the glock * @state: the requested state
@@ -410,7 +392,7 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = { .go_demote_ok = rgrp_go_demote_ok, .go_lock = rgrp_go_lock, .go_unlock = rgrp_go_unlock, - .go_dump = rgrp_go_dump, + .go_dump = gfs2_rgrp_dump, .go_type = LM_TYPE_RGRP, .go_min_hold_time = HZ / 5, };
fs/gfs2/incore.h +4 -3
@@ -92,9 +92,10 @@ struct gfs2_rgrpd {unsigned int rd_bh_count;u32 rd_last_alloc;unsigned char rd_flags; -#define GFS2_RDF_CHECK 0x01/* Need to check for unlinked inodes */ -#define GFS2_RDF_NOALLOC 0x02/* rg prohibits allocation */ -#define GFS2_RDF_UPTODATE 0x04/* rg is up to date */ +#define GFS2_RDF_CHECK 0x10000000/* check for unlinked inodes */ +#define GFS2_RDF_UPTODATE 0x20000000/* rg is up to date */ +#define GFS2_RDF_ERROR 0x40000000/* error in rg */ +#define GFS2_RDF_MASK 0xf0000000/* mask for internal flags */ };enum gfs2_state_bits {
fs/gfs2/rgrp.c +43 -15
105 lines not on this page · raw message
fs/gfs2/rgrp.h +24 -23
78 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 12/24 GFS2: Add a rgrp bitmap full flag
During block allocation, it is useful to know if sections of disk are full on a finer grained basis than a single resource group. This can make a performance difference when resource groups have larger numbers of bitmap blocks, since we no longer have to search them all block by block in each individual bitmap.
The full flag is set on a per-bitmap basis when it has been searched and found to have no free space. It is then skipped in subsequent searches until the flag is reset. The resetting occurs if we have to drop the glock on the resource group for any reason, or if we deallocate some blocks within that resource group and thus free up some space.
fs/gfs2/incore.h +3 -0
@@ -64,9 +64,12 @@ struct gfs2_log_element {const struct gfs2_log_operations *le_ops; }; +#define GBF_FULL 1 +struct gfs2_bitmap {struct buffer_head *bi_bh;char *bi_clone; +unsigned long bi_flags;u32 bi_offset;u32 bi_start;u32 bi_len;
fs/gfs2/rgrp.c +47 -30
128 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 13/24 GFS2: Be more aggressive in reclaiming unlinked inodes
This patch increases the frequency with which gfs2 looks for unlinked, but still allocated inodes. Its the equivalent operation to ext3's orphan list, but done with bitmaps in the resource groups.
This also fixes a bug where a field in the rgrp was too small.
fs/gfs2/incore.h +1 -1
@@ -94,7 +94,7 @@ struct gfs2_rgrpd {struct gfs2_sbd *rd_sbd;unsigned int rd_bh_count;u32 rd_last_alloc; -unsigned char rd_flags; +u32 rd_flags;#define GFS2_RDF_CHECK 0x10000000/* check for unlinked inodes */ #define GFS2_RDF_UPTODATE 0x20000000/* rg is up to date */ #define GFS2_RDF_ERROR 0x40000000/* error in rg */
fs/gfs2/rgrp.c +3 -2
@@ -581,7 +581,6 @@ static int read_rindex_entry(struct gfs2_inode *ip, rgd->rd_gl->gl_object = rgd; rgd->rd_flags &= ~GFS2_RDF_UPTODATE ; - rgd->rd_flags |=GFS2_RDF_CHECK ;return error; }
@@ -703,6 +702,8 @@ static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) rg_flags =be32_to_cpu (str->rg_flags); rg_flags &= ~GFS2_RDF_MASK ; + rgd->rd_flags &=GFS2_RDF_MASK ; + rgd->rd_flags |= rg_flags; rgd->rd_free =be32_to_cpu (str->rg_free); rgd->rd_dinodes =be32_to_cpu (str->rg_dinodes); rgd->rd_igeneration =be64_to_cpu (str->rg_igeneration);
@@ -773,7 +774,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd)for (x =0 ; x < length; x++)clear_bit (GBF_FULL , &rgd->rd_bits[x].bi_flags);gfs2_rgrp_in (rgd, (rgd->rd_bits[0 ].bi_bh)->b_data); - rgd->rd_flags |=GFS2_RDF_UPTODATE ; + rgd->rd_flags |= (GFS2_RDF_UPTODATE |GFS2_RDF_CHECK ); }spin_lock (&sdp->sd_rindex_spin);
Signature · 1 line
1.6.0.6
PATCH 14/24 GFS2: Clean up some file names
This patch renames the ops_*.c files which have no counterpart without the ops_ prefix in order to shorten the name and make it more readable. In addition, ops_address.h (which was very small) is moved into inode.h and inode.h is cleaned up by adding extern where required.
fs/gfs2/Makefile +1 -1
@@ -1,7 +1,7 @@ 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 main.o meta_io.o \ - mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ + mount.o aops.o dentry.o export.o 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
fs/gfs2/aops.c new file +1145 -0
1,145 lines not on this page · raw message
fs/gfs2/bmap.c +0 -1
@@ -25,7 +25,6 @@#include "trans.h" #include "dir.h" #include "util.h" -#include "ops_address.h" /* This doesn't need to be that large as max 64 bit pointers in a 4k * block is 512, so __u16 is fine for that. It saves stack space to
fs/gfs2/dentry.c new file +114 -0
114 lines not on this page · raw message
fs/gfs2/export.c new file +285 -0
285 lines not on this page · raw message
fs/gfs2/file.c new file +765 -0
765 lines not on this page · raw message
fs/gfs2/inode.c +0 -1
@@ -30,7 +30,6 @@#include "inode.h" #include "log.h" #include "meta_io.h" -#include "ops_address.h" #include "quota.h" #include "rgrp.h" #include "trans.h"
fs/gfs2/inode.h +33 -24
71 lines not on this page · raw message
fs/gfs2/meta_io.c +0 -1
@@ -31,7 +31,6 @@#include "rgrp.h" #include "trans.h" #include "util.h" -#include "ops_address.h" static int gfs2_aspace_writepage (struct page *page,struct writeback_control *wbc) {
fs/gfs2/ops_address.c deleted +0 -1146
591 lines not on this page · raw message
fs/gfs2/ops_dentry.c deleted +0 -114
114 lines not on this page · raw message
fs/gfs2/ops_export.c deleted +0 -285
285 lines not on this page · raw message
fs/gfs2/ops_file.c deleted +0 -766
766 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.6
Part of the diff is not shown here. View the raw message.
PATCH 15/24 GFS2: Merge mount.c and ops_super.c into super.c
mount.c only contained a single function, so is not really worth retaining on its own. All of the super related code is now either in super.c or ops_fstype.c
fs/gfs2/Makefile +2 -2
@@ -1,8 +1,8 @@ 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 main.o meta_io.o \ - mount.o aops.o dentry.o export.o file.o \ - ops_fstype.o ops_inode.o ops_super.o quota.o \ + aops.o dentry.o export.o file.o \ + ops_fstype.o ops_inode.o quota.o \ recovery.o rgrp.o super.o sys.o trans.o util.o gfs2-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o
fs/gfs2/mount.c deleted +0 -195
195 lines not on this page · raw message
fs/gfs2/ops_super.c deleted +0 -757
757 lines not on this page · raw message
fs/gfs2/super.c +901 -2
924 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 16/24 GFS2: Move gfs2_rmdiri into ops_inode.c
Move gfs2_rmdiri() into ops_inode.c and make it static.
fs/gfs2/inode.c +0 -52
@@ -1046,58 +1046,6 @@ fail:return ERR_PTR (error); } -/** -* gfs2_rmdiri - Remove a directory -* @dip: The parent directory of the directory to be removed -* @name: The name of the directory to be removed -* @ip: The GFS2 inode of the directory to be removed -* -* Assumes Glocks on dip and ip are held -* -* Returns: errno -*/ - -int gfs2_rmdiri (struct gfs2_inode *dip,const struct qstr *name, -struct gfs2_inode *ip) -{ -struct qstr dotname; -int error; - -if (ip->i_entries !=2 ) { -if (gfs2_consist_inode (ip)) -gfs2_dinode_print (ip); -return -EIO ; - } - - error =gfs2_dir_del (dip, name); -if (error) -return error; - - error =gfs2_change_nlink (dip,-1 ); -if (error) -return error; - -gfs2_str2qstr (&dotname,"." ); - error =gfs2_dir_del (ip, &dotname); -if (error) -return error; - -gfs2_str2qstr (&dotname,".." ); - error =gfs2_dir_del (ip, &dotname); -if (error) -return error; - -/* It looks odd, but it really should be done twice */ - error =gfs2_change_nlink (ip,-1 ); -if (error) -return error; - - error =gfs2_change_nlink (ip,-1 ); -if (error) -return error; - -return error; -}/* * gfs2_unlink_ok - check to see that a inode is still in a directory
fs/gfs2/inode.h +0 -2
@@ -96,8 +96,6 @@ extern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,extern struct inode *gfs2_createi (struct gfs2_holder *ghs,const struct qstr *name,unsigned int mode,dev_t dev); -extern int gfs2_rmdiri (struct gfs2_inode *dip,const struct qstr *name, -struct gfs2_inode *ip);extern int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name,const struct gfs2_inode *ip);extern int gfs2_permission (struct inode *inode,int mask);
fs/gfs2/ops_inode.c +53 -0
59 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 17/24 GFS2: Move gfs2_readlinki into ops_inode.c
Move gfs2_readlinki into ops_inode.c and make it static
fs/gfs2/inode.c +1 -57
@@ -1085,63 +1085,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,return 0 ; } -/** -* gfs2_readlinki - return the contents of a symlink -* @ip: the symlink's inode -* @buf: a pointer to the buffer to be filled -* @len: a pointer to the length of @buf -* -* If @buf is too small, a piece of memory is kmalloc()ed and needs -* to be freed by the caller. -* -* Returns: errno -*/ - -int gfs2_readlinki (struct gfs2_inode *ip,char **buf,unsigned int *len) -{ -struct gfs2_holder i_gh; -struct buffer_head *dibh; -unsigned int x; -int error; - -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,0 , &i_gh); - error =gfs2_glock_nq (&i_gh); -if (error) { -gfs2_holder_uninit (&i_gh); -return error; - } - -if (!ip->i_disksize) { -gfs2_consist_inode (ip); - error = -EIO ; - goto out; - } - - error =gfs2_meta_inode_buffer (ip, &dibh); -if (error) - goto out; - - x = ip->i_disksize +1 ; -if (x > *len) { - *buf =kmalloc (x,GFP_NOFS ); -if (!*buf) { - error = -ENOMEM ; - goto out_brelse; - } - } - -memcpy (*buf, dibh->b_data +sizeof (struct gfs2_dinode ), x); - *len = x; - -out_brelse: -brelse (dibh); -out: -gfs2_glock_dq_uninit (&i_gh); -return error; -} - -static int -__gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr) +static int __gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr) {struct buffer_head *dibh;int error;
fs/gfs2/inode.h +0 -1
@@ -99,7 +99,6 @@ extern struct inode *gfs2_createi(struct gfs2_holder *ghs,extern int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name,const struct gfs2_inode *ip);extern int gfs2_permission (struct inode *inode,int mask); -extern int gfs2_readlinki (struct gfs2_inode *ip,char **buf,unsigned int *len);extern int gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr);extern struct inode *gfs2_lookup_simple (struct inode *dip,const char *name);extern void gfs2_dinode_out (const struct gfs2_inode *ip,void *buf);
fs/gfs2/ops_inode.c +55 -0
61 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 18/24 GFS2: Move gfs2_unlink_ok into ops_inode.c
Another function which is only called from one ops_inode.c so we move it and make it static.
fs/gfs2/inode.c +0 -39
@@ -1046,45 +1046,6 @@ fail:return ERR_PTR (error); } - -/* -* gfs2_unlink_ok - check to see that a inode is still in a directory -* @dip: the directory -* @name: the name of the file -* @ip: the inode -* -* Assumes that the lock on (at least) @dip is held. -* -* Returns: 0 if the parent/child relationship is correct, errno if it isn't -*/ - -int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name, -const struct gfs2_inode *ip) -{ -int error; - -if (IS_IMMUTABLE (&ip->i_inode) ||IS_APPEND (&ip->i_inode)) -return -EPERM ; - -if ((dip->i_inode.i_mode &S_ISVTX ) && - dip->i_inode.i_uid !=current_fsuid () && - ip->i_inode.i_uid !=current_fsuid () && !capable (CAP_FOWNER )) -return -EPERM ; - -if (IS_APPEND (&dip->i_inode)) -return -EPERM ; - - error =gfs2_permission (&dip->i_inode,MAY_WRITE |MAY_EXEC ); -if (error) -return error; - - error =gfs2_dir_check (&dip->i_inode, name, ip); -if (error) -return error; - -return 0 ; -} -static int __gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr) {struct buffer_head *dibh;
fs/gfs2/inode.h +0 -2
@@ -96,8 +96,6 @@ extern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,extern struct inode *gfs2_createi (struct gfs2_holder *ghs,const struct qstr *name,unsigned int mode,dev_t dev); -extern int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name, -const struct gfs2_inode *ip);extern int gfs2_permission (struct inode *inode,int mask);extern int gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr);extern struct inode *gfs2_lookup_simple (struct inode *dip,const char *name);
fs/gfs2/ops_inode.c +38 -0
@@ -262,6 +262,44 @@ out_parent:return error; } +/* +* gfs2_unlink_ok - check to see that a inode is still in a directory +* @dip: the directory +* @name: the name of the file +* @ip: the inode +* +* Assumes that the lock on (at least) @dip is held. +* +* Returns: 0 if the parent/child relationship is correct, errno if it isn't +*/ + +static int gfs2_unlink_ok (struct gfs2_inode *dip,const struct qstr *name, +const struct gfs2_inode *ip) +{ +int error; + +if (IS_IMMUTABLE (&ip->i_inode) ||IS_APPEND (&ip->i_inode)) +return -EPERM ; + +if ((dip->i_inode.i_mode &S_ISVTX ) && + dip->i_inode.i_uid !=current_fsuid () && + ip->i_inode.i_uid !=current_fsuid () && !capable (CAP_FOWNER )) +return -EPERM ; + +if (IS_APPEND (&dip->i_inode)) +return -EPERM ; + + error =gfs2_permission (&dip->i_inode,MAY_WRITE |MAY_EXEC ); +if (error) +return error; + + error =gfs2_dir_check (&dip->i_inode, name, ip); +if (error) +return error; + +return 0 ; +} +/** * gfs2_unlink - Unlink a file * @dir: The inode of the directory containing the file to unlink
Signature · 1 line
1.6.0.6
PATCH 19/24 GFS2: Remove lockstruct subdir from gfs2 sysfs files
The lockstruct sub directory contained two entries, both of which are duplicated elsewhere in the gfs2 sysfs files as well as being available via /proc/mounts. There is no userland program using either of them, so this patch removes them.
fs/gfs2/sys.c +8 -33
@@ -276,25 +276,6 @@ static struct kobj_type gfs2_ktype = { .sysfs_ops = &gfs2_attr_ops, }; -/* -* display struct lm_lockstruct fields -*/ - -#define LOCKSTRUCT_ATTR (name, fmt) \ -static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ -{ \ - return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \ -} \ -static struct gfs2_attr lockstruct_attr_##name = __ATTR_RO(name) - -LOCKSTRUCT_ATTR (jid,"%u\n" ); -LOCKSTRUCT_ATTR (first,"%u\n" ); - -static struct attribute *lockstruct_attrs[] = { - &lockstruct_attr_jid.attr, - &lockstruct_attr_first.attr, -NULL , -};/* * lock_module. Originally from lock_dlm
@@ -397,6 +378,11 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)return sprintf (buf,"%d\n" , ls->ls_recover_jid_status); } +static ssize_t jid_show (struct gfs2_sbd *sdp,char *buf) +{ +return sprintf (buf,"%u\n" , sdp->sd_lockstruct.ls_jid); +} +#define GDLM_ATTR (_name,_mode,_show,_store) \ static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
@@ -404,6 +390,7 @@ GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);GDLM_ATTR (block,0644 , block_show, block_store);GDLM_ATTR (withdraw,0644 , withdraw_show, withdraw_store);GDLM_ATTR (id,0444 , lkid_show,NULL ); +GDLM_ATTR (jid,0444 , jid_show,NULL );GDLM_ATTR (first,0444 , lkfirst_show,NULL );GDLM_ATTR (first_done,0444 , first_done_show,NULL );GDLM_ATTR (recover,0200 ,NULL , recover_store);
@@ -415,7 +402,7 @@ static struct attribute *lock_module_attrs[] = { &gdlm_attr_block.attr, &gdlm_attr_withdraw.attr, &gdlm_attr_id.attr, - &lockstruct_attr_jid.attr, + &gdlm_attr_jid.attr, &gdlm_attr_first.attr, &gdlm_attr_first_done.attr, &gdlm_attr_recover.attr,
@@ -558,11 +545,6 @@ static struct attribute *tune_attrs[] = { NULL, }; -static struct attribute_group lockstruct_group = { - .name ="lockstruct" , - .attrs = lockstruct_attrs, -}; -static struct attribute_group args_group = { .name ="args" , .attrs = args_attrs,
@@ -588,13 +570,9 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)if (error) goto fail; - error =sysfs_create_group (&sdp->sd_kobj, &lockstruct_group); -if (error) - goto fail_reg; - error =sysfs_create_group (&sdp->sd_kobj, &args_group);if (error) - goto fail_lockstruct; + goto fail_reg; error =sysfs_create_group (&sdp->sd_kobj, &tune_group);if (error)
@@ -611,8 +589,6 @@ fail_tune:sysfs_remove_group (&sdp->sd_kobj, &tune_group); fail_args:sysfs_remove_group (&sdp->sd_kobj, &args_group); -fail_lockstruct: -sysfs_remove_group (&sdp->sd_kobj, &lockstruct_group); fail_reg:kobject_put (&sdp->sd_kobj); fail:
@@ -624,7 +600,6 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp) {sysfs_remove_group (&sdp->sd_kobj, &tune_group);sysfs_remove_group (&sdp->sd_kobj, &args_group); -sysfs_remove_group (&sdp->sd_kobj, &lockstruct_group);sysfs_remove_group (&sdp->sd_kobj, &lock_module_group);kobject_put (&sdp->sd_kobj); }
Signature · 1 line
1.6.0.6
PATCH 20/24 GFS2: Remove args subdir from gfs2 sysfs files
Since we can cat /proc/mounts there is no need to have this subdirectory in the gfs2 sysfs files. In fact this does not reflect the full range of possible mount argumenmts, where as /proc/mounts does.
There was only one userland user of this set of sysfs files and it will function perfectly well without these files being present (in fact that subcommand of gfs2_tool is obsolete anyway).
The tune/* subdirectory is also considered mostly obsolete, but there are a few uses of this until mount arguments can be added for the last few functions for which there are no equivalents currently. However the tune/* directory is still in my sights and new code should avoid using it. Only the gfs2_quota and gfs2_tool programs are know to use tune/* at the moment.
fs/gfs2/sys.c +1 -51
@@ -411,44 +411,6 @@ static struct attribute *lock_module_attrs[] = { NULL, }; -#define ARGS_ATTR (name, fmt) \ -static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ -{ \ - return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \ -} \ -static struct gfs2_attr args_attr_##name = __ATTR_RO(name) - -ARGS_ATTR (lockproto,"%s\n" ); -ARGS_ATTR (locktable,"%s\n" ); -ARGS_ATTR (hostdata,"%s\n" ); -ARGS_ATTR (spectator,"%d\n" ); -ARGS_ATTR (ignore_local_fs,"%d\n" ); -ARGS_ATTR (localcaching,"%d\n" ); -ARGS_ATTR (localflocks,"%d\n" ); -ARGS_ATTR (debug,"%d\n" ); -ARGS_ATTR (upgrade,"%d\n" ); -ARGS_ATTR (posix_acl,"%d\n" ); -ARGS_ATTR (quota,"%u\n" ); -ARGS_ATTR (suiddir,"%d\n" ); -ARGS_ATTR (data,"%d\n" ); - -static struct attribute *args_attrs[] = { - &args_attr_lockproto.attr, - &args_attr_locktable.attr, - &args_attr_hostdata.attr, - &args_attr_spectator.attr, - &args_attr_ignore_local_fs.attr, - &args_attr_localcaching.attr, - &args_attr_localflocks.attr, - &args_attr_debug.attr, - &args_attr_upgrade.attr, - &args_attr_posix_acl.attr, - &args_attr_quota.attr, - &args_attr_suiddir.attr, - &args_attr_data.attr, -NULL , -}; -/* * get and set struct gfs2_tune fields */
@@ -545,11 +507,6 @@ static struct attribute *tune_attrs[] = { NULL, }; -static struct attribute_group args_group = { - .name ="args" , - .attrs = args_attrs, -}; -static struct attribute_group tune_group = { .name ="tune" , .attrs = tune_attrs,
@@ -570,13 +527,9 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)if (error) goto fail; - error =sysfs_create_group (&sdp->sd_kobj, &args_group); -if (error) - goto fail_reg; - error =sysfs_create_group (&sdp->sd_kobj, &tune_group);if (error) - goto fail_args; + goto fail_reg; error =sysfs_create_group (&sdp->sd_kobj, &lock_module_group);if (error)
@@ -587,8 +540,6 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) fail_tune:sysfs_remove_group (&sdp->sd_kobj, &tune_group); -fail_args: -sysfs_remove_group (&sdp->sd_kobj, &args_group); fail_reg:kobject_put (&sdp->sd_kobj); fail:
@@ -599,7 +550,6 @@ fail:void gfs2_sys_fs_del (struct gfs2_sbd *sdp) {sysfs_remove_group (&sdp->sd_kobj, &tune_group); -sysfs_remove_group (&sdp->sd_kobj, &args_group);sysfs_remove_group (&sdp->sd_kobj, &lock_module_group);kobject_put (&sdp->sd_kobj); }
Signature · 1 line
1.6.0.6
PATCH 21/24 GFS2: smbd proccess hangs with flock() call.
From: Abhijith Das <[email protected]>
GFS2 currently does not support mandatory flocks. An flock() call with LOCK_MAND triggers unexpected behavior because gfs2 is not checking for this lock type. This patch corrects that.
fs/gfs2/file.c +2 -2
@@ -698,8 +698,8 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)if (!(fl->fl_flags &FL_FLOCK ))return -ENOLCK ; -if (__mandatory_lock (&ip->i_inode)) -return -ENOLCK ; +if (fl->fl_type &LOCK_MAND ) +return -EOPNOTSUPP ;if (fl->fl_type ==F_UNLCK ) {do_unflock (file, fl);
Signature · 1 line
1.6.0.6
PATCH 22/24 GFS2: Remove unused variable
fs/gfs2/file.c +0 -2
@@ -694,8 +694,6 @@ static void do_unflock(struct file *file, struct file_lock *fl)static int gfs2_flock (struct file *file,int cmd,struct file_lock *fl) { -struct gfs2_inode *ip =GFS2_I (file->f_mapping->host); -if (!(fl->fl_flags &FL_FLOCK ))return -ENOLCK ;if (fl->fl_type &LOCK_MAND )
Signature · 1 line
1.6.0.6
PATCH 23/24 GFS2: Fix locking issue mounting gfs2meta fs
This patch uses sget() to get a reference to the existing gfs2 sb when mouting the gfs2meta filesystem (in fact thats just another mount of the gfs2 filesystem with a different root and this interface is for backward compatibility).
fs/gfs2/ops_fstype.c +22 -14
@@ -1273,9 +1273,20 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags,return get_sb_bdev (fs_type, flags, dev_name, data, fill_super, mnt); } +static int test_meta_super (struct super_block *s,void *ptr) +{ +struct block_device *bdev = ptr; +return (bdev == s->s_bdev); +} + +static int set_meta_super (struct super_block *s,void *ptr) +{ +return -EINVAL ; +} +static struct super_block *get_gfs2_sb (const char *dev_name) { -struct super_block *sb; +struct super_block *s;struct path path;int error;
@@ -1283,30 +1294,27 @@ static struct super_block *get_gfs2_sb(const char *dev_name)if (error) {printk (KERN_WARNING "GFS2: path_lookup on %s returned error %d\n" , dev_name, error); -return NULL ; +return ERR_PTR (-ENOENT ); } - sb = path.dentry->d_inode->i_sb; -if (sb && (sb->s_type == &gfs2_fs_type)) -atomic_inc (&sb->s_active); -else - sb =NULL ; + s =sget (&gfs2_fs_type, test_meta_super, set_meta_super, + path.dentry->d_inode->i_sb->s_bdev);path_put (&path); -return sb; +return s; }static int gfs2_get_sb_meta (struct file_system_type *fs_type,int flags,const char *dev_name,void *data,struct vfsmount *mnt) { -struct super_block *sb =NULL ; +struct super_block *s;struct gfs2_sbd *sdp; - sb =get_gfs2_sb (dev_name); -if (!sb) { + s =get_gfs2_sb (dev_name); +if (IS_ERR (s)) {printk (KERN_WARNING "GFS2: gfs2 mount does not exist\n" ); -return -ENOENT ; +return PTR_ERR (s); } - sdp = sb->s_fs_info; - mnt->mnt_sb = sb; + sdp = s->s_fs_info; + mnt->mnt_sb = s; mnt->mnt_root =dget (sdp->sd_master_dir);return 0 ; }
Signature · 1 line
1.6.0.6
PATCH 24/24 GFS2: Fix cache coherency between truncate and O_DIRECT read
If a page was partially zeroed as the result of a truncate, then it was not being correctly marked dirty. This resulted in the deleted data reappearing if the file was read back via direct I/O.
fs/gfs2/bmap.c +1 -1
@@ -1012,7 +1012,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping)gfs2_trans_add_bh (ip->i_gl, bh,0 );zero_user (page, offset, length); - +mark_buffer_dirty (bh); unlock:unlock_page (page);page_cache_release (page);
Signature · 1 line
1.6.0.6
Re: [PATCH 23/24] GFS2: Fix locking issue mounting gfs2meta fs
In reply to Steven Whitehousefs/gfs2/ops_fstype.c static int gfs2_get_sb(struct file_system_type *fs_type, int flags, · line 1278
Quoted 3 lines · Steven Whitehouse
static struct
super_block*get_gfs2_sb(const char*dev_name) {fs/gfs2/ops_fstype.c +0
-1-struct super_block *sb;
Any reason you don't merge get_gfs2_sb into gfs2_get_sb_meta? That's how most other get_sb callbacks are structured, and would also get rid of the rather confusing get_gfs2_sb name.
Re: [PATCH 23/24] GFS2: Fix locking issue mounting gfs2meta fs
Hi,
Quoted 9 lines · Christoph Hellwig
fs/gfs2/ops_fstype.c static int gfs2_get_sb(struct file_system_type *fs_type, int flags, · line 1278
Quoted 3 lines · Steven Whitehouse
static struct
super_block*get_gfs2_sb(const char*dev_name) {fs/gfs2/ops_fstype.c +0
-1-struct super_block *sb;Any reason you don't merge
get_gfs2_sbintogfs2_get_sb_meta? That's how most otherget_sbcallbacks are structured, and would also get rid of the rather confusingget_gfs2_sbname.
Well originally I was expecting to share that code with the gfs2_get_sb() but since that patch has been dropped now, I guess there is no reason not to merge them,
Steve.
GFS2: Merge gfs2_get_sb into gfs2_get_sb_meta
In reply to Christoph HellwigQuoted 1 line
From
003dec8913d6bebb4ecc989ec04a235cf38f5ea9Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Wed, 10 Jun 2009 10:31:45 +0100
Subject: [PATCH] GFS2: Merge gfs2_get_sb into gfs2_get_sb_meta
These don't need to be separate functions.
fs/gfs2/ops_fstype.c +4 -12
@@ -1284,9 +1284,11 @@ static int set_meta_super(struct super_block *s, void *ptr)return -EINVAL ; } -static struct super_block *get_gfs2_sb (const char *dev_name) +static int gfs2_get_sb_meta (struct file_system_type *fs_type,int flags, +const char *dev_name,void *data,struct vfsmount *mnt) {struct super_block *s; +struct gfs2_sbd *sdp;struct path path;int error;
@@ -1294,21 +1296,11 @@ static struct super_block *get_gfs2_sb(const char *dev_name)if (error) {printk (KERN_WARNING "GFS2: path_lookup on %s returned error %d\n" , dev_name, error); -return ERR_PTR (-ENOENT ); +return error; } s =sget (&gfs2_fs_type, test_meta_super, set_meta_super, path.dentry->d_inode->i_sb->s_bdev);path_put (&path); -return s; -} - -static int gfs2_get_sb_meta (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data,struct vfsmount *mnt) -{ -struct super_block *s; -struct gfs2_sbd *sdp; - - s =get_gfs2_sb (dev_name);if (IS_ERR (s)) {printk (KERN_WARNING "GFS2: gfs2 mount does not exist\n" );return PTR_ERR (s);
Signature · 1 line
1.6.0.6
Re: [PATCH 10/24] GFS2: Don't warn when delete inode fails on ro filesystem
In reply to Steven WhitehouseQuoted 2 lines · Steven Whitehouse
If the filesystem is read-only, then we expect that delete inode will fail, so there is no need to warn about it.
Umm, ->delete_inode should never be called on a read-only filesystem by the VFS.
Re: [PATCH 10/24] GFS2: Don't warn when delete inode fails on ro filesystem
Hi,
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Steven Whitehouse
If the filesystem is read-only, then we expect that delete inode will fail, so there is no need to warn about it.
Umm, ->delete_inode should never be called on a read-only filesystem by the VFS.
On a single node, thats true. With multiple nodes, some mounted ro and some mounted rw, sometimes the ro node gets the baton passed to it, if it happens to have a process holding open an inode thats been unlinked on the rw node. In that case it has to ignore it and one of the rw nodes will deal with the deallocation later,
Steve.