ocfs2 updates
PATCH 1/1 ocfs2 updates
Please pull from 'upstream-linus' branch ofgit://oss.oracle.com/home/sourcebo/git/ocfs2.git
to receive the following updates:
fs/ocfs2/cluster/masklog.c | 1 fs/ocfs2/cluster/masklog.h | 2 fs/ocfs2/cluster/nodemanager.c | 4 - fs/ocfs2/cluster/tcp.c | 14 +++- fs/ocfs2/cluster/tcp.h | 5 - fs/ocfs2/dlm/dlmcommon.h | 8 -- fs/ocfs2/dlm/dlmdebug.c | 12 +-- fs/ocfs2/dlm/dlmdomain.c | 39 ++++++------ fs/ocfs2/dlm/dlmmaster.c | 4 - fs/ocfs2/dlm/dlmrecovery.c | 23 +++---- fs/ocfs2/extent_map.c | 38 +++++++++++- fs/ocfs2/file.c | 51 ---------------- fs/ocfs2/heartbeat.c | 1 fs/ocfs2/inode.c | 46 ++++++++++++++- fs/ocfs2/journal.c | 124 ++++++++++++++++++++++++++++++----------- fs/ocfs2/ocfs2.h | 7 +- fs/ocfs2/ocfs2_fs.h | 1 fs/ocfs2/super.c | 11 +++ 18 files changed, 249 insertions(+), 142 deletions(-)
Jeff Mahoney:
ocfs2: fix -Wformat warnings when building UML on x86-64
ocfs2: complete failure recovery for nodemanager init
Joel Becker:
ocfs2: Set .owner on masklog sysfs attributes.
ocfs2: Respond to on-disk corruption in the extent map code.
Mark Fasheh:
ocfs2: remove pointless max journal size limit
ocfs2: remove unused code
ocfs2: remove non existing function prototypes
ocfs2: fix orphan recovery deadlock
ocfs2: use hlists for lockres hash
Sunil Mushran:
ocfs2: added source addr to bind() in o2net_start_connect()
fs/ocfs2/cluster/masklog.c +1 -0
@@ -74,6 +74,7 @@ struct mlog_attribute {#define define_mask (_name) { \ .attr = { \ .name = #_name, \ + .owner = THIS_MODULE, \ .mode = S_IRUGO | S_IWUSR, \ }, \ .mask = ML_##_name, \
fs/ocfs2/cluster/masklog.h +1 -1
@@ -256,7 +256,7 @@ extern struct mlog_bits mlog_and_bits, m } \ } while (0) -#if (BITS_PER_LONG ==32 ) || defined(CONFIG_X86_64 ) +#if (BITS_PER_LONG ==32 ) || defined(CONFIG_X86_64 ) || (defined(CONFIG_UML_X86 ) && defined(CONFIG_64BIT ))#define MLFi64 "lld"#define MLFu64 "llu"#define MLFx64 "llx"
fs/ocfs2/cluster/nodemanager.c +3 -1
@@ -756,7 +756,7 @@ static int __init init_o2nm(void)if (!ocfs2_table_header) {printk (KERN_ERR "nodemanager: unable to register sysctl\n" ); ret = -ENOMEM ;/* or something. */ - goto out; + goto out_o2net; } ret =o2net_register_hb_callbacks ();
@@ -780,6 +780,8 @@ out_callbacks:o2net_unregister_hb_callbacks (); out_sysctl:unregister_sysctl_table (ocfs2_table_header); +out_o2net: +o2net_exit (); out:return ret; }
fs/ocfs2/cluster/tcp.c +12 -2
@@ -1318,7 +1318,7 @@ static void o2net_start_connect(void *ar {struct o2net_node *nn = arg;struct o2net_sock_container *sc =NULL ; -struct o2nm_node *node =NULL ; +struct o2nm_node *node =NULL , *mynode =NULL ;struct socket *sock =NULL ;struct sockaddr_in myaddr = {0 , }, remoteaddr = {0 , };int ret =0 ;
@@ -1334,6 +1334,12 @@ static void o2net_start_connect(void *ar goto out; } + mynode =o2nm_get_node_by_num (o2nm_this_node ()); +if (mynode ==NULL ) { + ret =0 ; + goto out; + } +spin_lock (&nn->nn_lock);/* see if we already have one pending or have given up */ if (nn->nn_sc || nn->nn_persistent_error)
@@ -1361,12 +1367,14 @@ static void o2net_start_connect(void *ar sock->sk->sk_allocation =GFP_ATOMIC ; myaddr.sin_family =AF_INET ; + myaddr.sin_addr.s_addr = (__force u32 )mynode->nd_ipv4_address; myaddr.sin_port = (__force u16 )htons (0 );/* any port */ ret = sock->ops->bind (sock, (struct sockaddr *)&myaddr,sizeof (myaddr));if (ret) { -mlog (0 ,"bind failed: %d\n" , ret); +mlog (ML_ERROR ,"bind failed with %d at address %u.%u.%u.%u\n" , + ret,NIPQUAD (mynode->nd_ipv4_address)); goto out; }
@@ -1407,6 +1415,8 @@ out:sc_put (sc);if (node)o2nm_node_put (node); +if (mynode) +o2nm_node_put (mynode);return ; }
fs/ocfs2/cluster/tcp.h +0 -5
@@ -85,13 +85,10 @@ enum { O2NET_DRIVER_READY, }; -int o2net_init_tcp_sock (struct inode *inode);int o2net_send_message (u32 msg_type,u32 key,void *data,u32 len,u8 target_node,int *status);int o2net_send_message_vec (u32 msg_type,u32 key,struct kvec *vec,size_t veclen,u8 target_node,int *status); -int o2net_broadcast_message (u32 msg_type,u32 key,void *data,u32 len, -struct inode *group); int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, o2net_msg_handler_func *func, void *data,
@@ -107,7 +104,5 @@ void o2net_disconnect_node(struct o2nm_nint o2net_init (void );void o2net_exit (void ); -int o2net_proc_init (struct proc_dir_entry *parent); -void o2net_proc_exit (struct proc_dir_entry *parent);#endif /* O2CLUSTER_TCP_H */
fs/ocfs2/dlm/dlmcommon.h +3 -5
@@ -37,9 +37,7 @@#define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes#define DLM_THREAD_MS 200 // flush at least every 200 ms -#define DLM_HASH_BITS 7 -#define DLM_HASH_SIZE (1 << DLM_HASH_BITS) -#define DLM_HASH_MASK (DLM_HASH_SIZE - 1) +#define DLM_HASH_BUCKETS (PAGE_SIZE / sizeof(struct hlist_head))enum dlm_ast_type {DLM_AST =0 ,
@@ -87,7 +85,7 @@ enum dlm_ctxt_state {struct dlm_ctxt {struct list_head list; -struct list_head *resources; +struct hlist_head *lockres_hash;struct list_head dirty_list;struct list_head purge_list;struct list_head pending_asts;
@@ -217,7 +215,7 @@ struct dlm_lock_resource {/* WARNING: Please see the comment in dlm_init_lockres before * adding fields here. */ -struct list_head list; +struct hlist_node hash_node;struct kref refs;/* please keep these next 3 in this order
fs/ocfs2/dlm/dlmdebug.c +5 -7
@@ -117,8 +117,8 @@ EXPORT_SYMBOL_GPL(dlm_print_one_lock);void dlm_dump_lock_resources (struct dlm_ctxt *dlm) {struct dlm_lock_resource *res; -struct list_head *iter; -struct list_head *bucket; +struct hlist_node *iter; +struct hlist_head *bucket;int i; mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n",
@@ -129,12 +129,10 @@ void dlm_dump_lock_resources(struct dlm_ }spin_lock (&dlm->spinlock); -for (i=0 ; i<DLM_HASH_SIZE ; i++) { - bucket = &(dlm->resources[i]); -list_for_each (iter, bucket) { - res = list_entry(iter, struct dlm_lock_resource, list); +for (i=0 ; i<DLM_HASH_BUCKETS ; i++) { + bucket = &(dlm->lockres_hash[i]); +hlist_for_each_entry (res, iter, bucket, hash_node)dlm_print_one_lock_resource (res); - } }spin_unlock (&dlm->spinlock); }
fs/ocfs2/dlm/dlmdomain.c +19 -20
@@ -77,26 +77,26 @@ static void dlm_unregister_domain_handlevoid __dlm_unhash_lockres (struct dlm_lock_resource *lockres) { -list_del_init (&lockres->list); +hlist_del_init (&lockres->hash_node);dlm_lockres_put (lockres); }void __dlm_insert_lockres (struct dlm_ctxt *dlm,struct dlm_lock_resource *res) { -struct list_head *bucket; +struct hlist_head *bucket;struct qstr *q;assert_spin_locked (&dlm->spinlock); q = &res->lockname; q->hash =full_name_hash (q->name, q->len); - bucket = &(dlm->resources[q->hash &DLM_HASH_MASK ]); + bucket = &(dlm->lockres_hash[q->hash %DLM_HASH_BUCKETS ]);/* get a reference for our hashtable */ dlm_lockres_get (res); -list_add_tail (&res->list, bucket); +hlist_add_head (&res->hash_node, bucket); } struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm,
@@ -104,9 +104,9 @@ struct dlm_lock_resource * __dlm_lookup_ unsigned int len) {unsigned int hash; -struct list_head *iter; +struct hlist_node *iter;struct dlm_lock_resource *tmpres=NULL ; -struct list_head *bucket; +struct hlist_head *bucket;mlog_entry ("%.*s\n" , len, name);
@@ -114,11 +114,11 @@ struct dlm_lock_resource * __dlm_lookup_ hash =full_name_hash (name, len); - bucket = &(dlm->resources[hash &DLM_HASH_MASK ]); + bucket = &(dlm->lockres_hash[hash %DLM_HASH_BUCKETS ]);/* check for pre-existing lock */ -list_for_each (iter, bucket) { - tmpres = list_entry(iter, struct dlm_lock_resource, list); +hlist_for_each (iter, bucket) { + tmpres = hlist_entry(iter, struct dlm_lock_resource, hash_node);if (tmpres->lockname.len == len &&memcmp (tmpres->lockname.name, name, len) ==0 ) {dlm_lockres_get (tmpres);
@@ -193,8 +193,8 @@ static int dlm_wait_on_domain_helper(constatic void dlm_free_ctxt_mem (struct dlm_ctxt *dlm) { -if (dlm->resources) -free_page ((unsigned long ) dlm->resources); +if (dlm->lockres_hash) +free_page ((unsigned long ) dlm->lockres_hash);if (dlm->name)kfree (dlm->name);
@@ -303,10 +303,10 @@ static void dlm_migrate_all_locks(structmlog (0 ,"Migrating locks from domain %s\n" , dlm->name); restart:spin_lock (&dlm->spinlock); -for (i=0 ; i<DLM_HASH_SIZE ; i++) { -while (!list_empty (&dlm->resources[i])) { - res =list_entry (dlm->resources[i].next, - struct dlm_lock_resource, list); +for (i =0 ; i <DLM_HASH_BUCKETS ; i++) { +while (!hlist_empty (&dlm->lockres_hash[i])) { + res =hlist_entry (dlm->lockres_hash[i].first, + struct dlm_lock_resource, hash_node);/* need reference when manually grabbing lockres */ dlm_lockres_get (res);/* this should unhash the lockres
@@ -1191,18 +1191,17 @@ static struct dlm_ctxt *dlm_alloc_ctxt(c goto leave; } - dlm->resources = (struct list_head *)__get_free_page (GFP_KERNEL ); -if (!dlm->resources) { + dlm->lockres_hash = (struct hlist_head *)__get_free_page (GFP_KERNEL ); +if (!dlm->lockres_hash) {mlog_errno (-ENOMEM );kfree (dlm->name);kfree (dlm); dlm =NULL ; goto leave; } -memset (dlm->resources,0 ,PAGE_SIZE ); -for (i=0 ; i<DLM_HASH_SIZE ; i++) -INIT_LIST_HEAD (&dlm->resources[i]); +for (i=0 ; i<DLM_HASH_BUCKETS ; i++) +INIT_HLIST_HEAD (&dlm->lockres_hash[i]);strcpy (dlm->name, domain); dlm->key = key;
fs/ocfs2/dlm/dlmmaster.c +2 -2
@@ -564,7 +564,7 @@ static void dlm_lockres_release(struct k/* By the time we're ready to blow this guy away, we shouldn't * be on any lists. */ -BUG_ON (!list_empty (&res->list)); +BUG_ON (!hlist_unhashed (&res->hash_node));BUG_ON (!list_empty (&res->granted));BUG_ON (!list_empty (&res->converting));BUG_ON (!list_empty (&res->blocked));
@@ -605,7 +605,7 @@ static void dlm_init_lockres(struct dlm_init_waitqueue_head (&res->wq);spin_lock_init (&res->spinlock); -INIT_LIST_HEAD (&res->list); +INIT_HLIST_NODE (&res->hash_node);INIT_LIST_HEAD (&res->granted);INIT_LIST_HEAD (&res->converting);INIT_LIST_HEAD (&res->blocked);
fs/ocfs2/dlm/dlmrecovery.c +12 -11
@@ -1693,7 +1693,10 @@ static void dlm_finish_local_lockres_rec u8 dead_node, u8 new_master) { int i; -struct list_head *iter, *iter2, *bucket; +struct list_head *iter, *iter2; +struct hlist_node *hash_iter; +struct hlist_head *bucket; +struct dlm_lock_resource *res;mlog_entry_void ();
@@ -1717,10 +1720,9 @@ static void dlm_finish_local_lockres_rec* for now we need to run the whole hash, clear * the RECOVERING state and set the owner * if necessary */ -for (i=0 ; i<DLM_HASH_SIZE ; i++) { - bucket = &(dlm->resources[i]); -list_for_each (iter, bucket) { - res = list_entry (iter, struct dlm_lock_resource, list); +for (i =0 ; i <DLM_HASH_BUCKETS ; i++) { + bucket = &(dlm->lockres_hash[i]); +hlist_for_each_entry (res, hash_iter, bucket, hash_node) {if (res->state &DLM_LOCK_RES_RECOVERING ) {if (res->owner == dead_node) { mlog(0, "(this=%u) res %.*s owner=%u "
@@ -1852,10 +1854,10 @@ static void dlm_free_dead_locks(struct dstatic void dlm_do_local_recovery_cleanup (struct dlm_ctxt *dlm,u8 dead_node) { -struct list_head *iter; +struct hlist_node *iter;struct dlm_lock_resource *res;int i; -struct list_head *bucket; +struct hlist_head *bucket;struct dlm_lock *lock;
@@ -1876,10 +1878,9 @@ static void dlm_do_local_recovery_cleanu* can be kicked again to see if any ASTs or BASTs * need to be fired as a result. */ -for (i=0 ; i<DLM_HASH_SIZE ; i++) { - bucket = &(dlm->resources[i]); -list_for_each (iter, bucket) { - res = list_entry (iter, struct dlm_lock_resource, list); +for (i =0 ; i <DLM_HASH_BUCKETS ; i++) { + bucket = &(dlm->lockres_hash[i]); +hlist_for_each_entry (res, iter, bucket, hash_node) {/* always prune any $RECOVERY entries for dead nodes, * otherwise hangs can occur during later recovery */ if (dlm_is_recovery_lock(res->lockname.name,
fs/ocfs2/extent_map.c +36 -2
@@ -181,6 +181,12 @@ static int ocfs2_extent_map_find_leaf(st ret = -EBADR ;if (rec_end >OCFS2_I (inode)->ip_clusters) {mlog_errno (ret); +ocfs2_error (inode->i_sb, +"Extent %d at e_blkno %" MLFu64" of inode %" MLFu64" goes past ip_clusters of %u\n" , + i, +le64_to_cpu (rec->e_blkno), +OCFS2_I (inode)->ip_blkno, +OCFS2_I (inode)->ip_clusters); goto out_free; }
@@ -226,6 +232,12 @@ static int ocfs2_extent_map_find_leaf(st ret = -EBADR ;if (blkno) {mlog_errno (ret); +ocfs2_error (inode->i_sb, +"Multiple extents for (cpos = %u, clusters = %u) on inode %" MLFu64"; e_blkno %" MLFu64" and rec %d at e_blkno %" MLFu64"\n" , + cpos, clusters, +OCFS2_I (inode)->ip_blkno, + blkno, i, +le64_to_cpu (rec->e_blkno)); goto out_free; }
@@ -238,6 +250,10 @@ static int ocfs2_extent_map_find_leaf(st*/ ret = -EBADR ;if (!blkno) { +ocfs2_error (inode->i_sb, +"No record found for (cpos = %u, clusters = %u) on inode %" MLFu64"\n" , + cpos, clusters, +OCFS2_I (inode)->ip_blkno);mlog_errno (ret); goto out_free; }
@@ -266,6 +282,20 @@ static int ocfs2_extent_map_find_leaf(stfor (i =0 ; i <le16_to_cpu (el->l_next_free_rec); i++) { rec = &el->l_recs[i]; + +if ((le32_to_cpu (rec->e_cpos) +le32_to_cpu (rec->e_clusters)) > +OCFS2_I (inode)->ip_clusters) { + ret = -EBADR ; +mlog_errno (ret); +ocfs2_error (inode->i_sb, +"Extent %d at e_blkno %" MLFu64" of inode %" MLFu64" goes past ip_clusters of %u\n" , + i, +le64_to_cpu (rec->e_blkno), +OCFS2_I (inode)->ip_blkno, +OCFS2_I (inode)->ip_clusters); +return ret; + } + ret =ocfs2_extent_map_insert (inode, rec,le16_to_cpu (el->l_tree_depth));if (ret) {
@@ -526,6 +556,10 @@ static int ocfs2_extent_map_insert(struc OCFS2_I(inode)->ip_map.em_clusters) { ret = -EBADR ;mlog_errno (ret); +ocfs2_error (inode->i_sb, +"Zero e_clusters on non-tail extent record at e_blkno %" MLFu64" on inode %" MLFu64"\n" , +le64_to_cpu (rec->e_blkno), +OCFS2_I (inode)->ip_blkno);return ret; }
@@ -588,12 +622,12 @@ static int ocfs2_extent_map_insert(struc* Existing record in the extent map: * * cpos = 10, len = 10 -* |---------| +* |---------| * * New Record: * * cpos = 10, len = 20 -* |------------------| +* |------------------| * * The passed record is the new on-disk record. The new_clusters value * is how many clusters were added to the file. If the append is a
fs/ocfs2/file.c +1 -50
81 lines not on this page · raw message
fs/ocfs2/heartbeat.c +1 -0
@@ -67,6 +67,7 @@ void ocfs2_init_node_maps(struct ocfs2_socfs2_node_map_init (&osb->mounted_map);ocfs2_node_map_init (&osb->recovery_map);ocfs2_node_map_init (&osb->umount_map); +ocfs2_node_map_init (&osb->osb_recovering_orphan_dirs); } static void ocfs2_do_node_down(int node_num,
fs/ocfs2/inode.c +45 -1
76 lines not on this page · raw message
fs/ocfs2/journal.c +93 -31
185 lines not on this page · raw message
fs/ocfs2/ocfs2.h +4 -3
@@ -174,9 +174,6 @@ enum ocfs2_mount_optionsOCFS2_MOUNT_NOINTR =1 <<2 ,/* Don't catch signals */ OCFS2_MOUNT_ERRORS_PANIC =1 <<3 ,/* Panic on errors */ OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */ -#ifdef OCFS2_ORACORE_WORKAROUNDS - OCFS2_MOUNT_COMPAT_OCFS = 1 << 30, /* ocfs1 compatibility mode */ -#endif };#define OCFS2_OSB_SOFT_RO 0x0001
@@ -290,6 +287,10 @@ struct ocfs2_superstruct inode *osb_tl_inode;struct buffer_head *osb_tl_bh;struct work_struct osb_truncate_log_wq; + +struct ocfs2_node_map osb_recovering_orphan_dirs; +unsigned int *osb_orphan_wipes; +wait_queue_head_t osb_wipe_event; };#define OCFS2_SB (sb) ((struct ocfs2_super *)(sb)->s_fs_info)
fs/ocfs2/ocfs2_fs.h +0 -1
@@ -138,7 +138,6 @@/* Journal limits (in bytes) */ #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) -#define OCFS2_MAX_JOURNAL_SIZE (500 * 1024 * 1024)struct ocfs2_system_inode_info {char *si_name;
fs/ocfs2/super.c +11 -0
@@ -1325,6 +1325,16 @@ static int ocfs2_initialize_super(struct }mlog (ML_NOTICE ,"max_slots for this device: %u\n" , osb->max_slots); +init_waitqueue_head (&osb->osb_wipe_event); + osb->osb_orphan_wipes =kcalloc (osb->max_slots, +sizeof (*osb->osb_orphan_wipes), +GFP_KERNEL ); +if (!osb->osb_orphan_wipes) { + status = -ENOMEM ; +mlog_errno (status); + goto bail; + } + osb->s_feature_compat =le32_to_cpu (OCFS2_RAW_SB (di)->s_feature_compat); osb->s_feature_ro_compat =
@@ -1638,6 +1648,7 @@ static void ocfs2_delete_osb(struct ocfsif (osb->slot_info)ocfs2_free_slot_info (osb->slot_info); +kfree (osb->osb_orphan_wipes);/* FIXME * This belongs in journal shutdown, but because we have to * allocate osb->journal at the start of ocfs2_initalize_osb(),
Review
Quoted 2 lines · Mark Fasheh
(quoted diff) +1
-0+ "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n",
Sometime, please consider killing MLFu64 and friends.
#if (BITS_PER_LONG == 32) || defined(CONFIG_X86_64) || (defined(CONFIG_UML_X86) && defined(CONFIG_64BIT)) #define MLFi64 "lld"
#define MLFu64 "llu"
#define MLFx64 "llx"
#else
#define MLFi64 "ld"
#define MLFu64 "lu"
#define MLFx64 "lx"
#endif
You covered most cases there, but sh64 implements u64 as `unsigned long long' (for example).
Generally we solve this problem by just using %ll and casting the args
appropriately. That does have some runtime cost on 32-bit.
u64 and s64 are the easy case - it gets stickier on things like sector_t whose size is controlled by a CONFIG_thing on 32-bit.
Quoted 5 lines · Andrew Morton
Review
Quoted 2 lines · Mark Fasheh
(quoted diff) +1
-0+ "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n",Sometime, please consider killing MLFu64 and friends.
Yeah, it's on my 'todo' list - enough people have asked now that it's clear folks don't want it. The original idea behind it all was to avoid all the casts involved. Anyway, I definitely intend to get to it.
Quoted 8 lines
You covered most cases there, but sh64 implements u64 as `unsigned long long' (for example).
Generally we solve this problem by just using %ll and casting the args
appropriately. That does have some runtime cost on 32-bit.u64 and s64 are the easy case - it gets stickier on things like
sector_twhose size is controlled by aCONFIG_thingon 32-bit.
Ah, cool. Thanks for pointing those out - it'll help as I try to remove this stuff.
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh at oracle.com