[Ocfs2-commits] manish commits r2283 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed May 18 21:16:56 CDT 2005


Author: manish
Signed-off-by: mfasheh
Date: 2005-05-18 21:16:54 -0500 (Wed, 18 May 2005)
New Revision: 2283

Modified:
   trunk/fs/ocfs2/super.c
Log:
Bad on-disk clustersize should be a mount failure, not a BUG(). Also,
some coding style consistency fixups along the way.

Signed-off-by: mfasheh


Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-19 00:40:58 UTC (rev 2282)
+++ trunk/fs/ocfs2/super.c	2005-05-19 02:16:54 UTC (rev 2283)
@@ -83,7 +83,7 @@
 static void ocfs_dismount_volume(struct super_block *sb, int mnt_err);
 static int ocfs_initialize_mem_caches(void);
 static void ocfs_free_mem_caches(void);
-static void ocfs_delete_osb(ocfs_super * osb);
+static void ocfs_delete_osb(ocfs_super *osb);
 
 static int ocfs_statfs(struct super_block *sb, struct kstatfs *buf);
 
@@ -93,12 +93,12 @@
 static int ocfs_init_local_system_inodes(ocfs_super *osb);
 static int ocfs_release_system_inodes(ocfs_super *osb);
 static int ocfs2_fill_local_node_info(ocfs_super *osb);
-static int ocfs_check_volume(ocfs_super * osb);
+static int ocfs_check_volume(ocfs_super *osb);
 static int ocfs_verify_volume(ocfs2_dinode *di, struct buffer_head *bh,
 			      u32 sectsize);
 static int ocfs_initialize_osb(ocfs_super *osb, struct buffer_head *bh);
 static int ocfs2_get_sector(struct super_block *sb, struct buffer_head **bh, int block, int sect_size);
-static void ocfs_write_super(struct super_block * sb);
+static void ocfs_write_super(struct super_block *sb);
 
 static unsigned long long ocfs2_max_file_offset(unsigned int blockshift);
 
@@ -120,7 +120,7 @@
 /*
  * write_super and sync_fs ripped right out of ext3.
  */
-static void ocfs_write_super (struct super_block * sb)
+static void ocfs_write_super(struct super_block *sb)
 {
 	if (down_trylock(&sb->s_lock) == 0)
 		BUG();
@@ -293,7 +293,7 @@
 	struct inode *inode = NULL;
 	ocfs_super *osb = NULL;
 
-	mlog_entry ("%p, %p, %i", sb, data, silent);
+	mlog_entry("%p, %p, %i", sb, data, silent);
 
 	/* for now we only have one cluster/node, make sure we see it
 	 * in the heartbeat universe */
@@ -340,7 +340,7 @@
 		goto read_super_error;
 	}
 
-	root = d_alloc_root (inode);
+	root = d_alloc_root(inode);
 	if (!root) {
 		status = -ENOMEM;
 		mlog_errno(status);
@@ -363,12 +363,12 @@
 
 read_super_error:
 	if (inode)
-		iput (inode);
+		iput(inode);
 
 	if (osb) {
 		atomic_set(&osb->vol_state, VOLUME_DISABLED);
 		wake_up(&osb->osb_mount_event);
-		ocfs_dismount_volume (sb, 1);
+		ocfs_dismount_volume(sb, 1);
 	}
 
 	mlog_exit(status);
@@ -396,7 +396,7 @@
 {
 	int status;
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	ocfs2_print_version();
 
@@ -410,9 +410,9 @@
 		goto leave;
 	}
 	
-	spin_lock (&ocfs2_globals_lock);
+	spin_lock(&ocfs2_globals_lock);
 	osb_id = 0;
-	spin_unlock (&ocfs2_globals_lock);
+	spin_unlock(&ocfs2_globals_lock);
 
 	/* Initialize the proc interface */
 	ocfs_proc_init();
@@ -423,10 +423,10 @@
 		exit_ocfs2_extent_maps();
 	}
 
-	mlog_exit (status);
+	mlog_exit(status);
 
 	if (status >= 0) {
-		return register_filesystem (&ocfs_fs_type);
+		return register_filesystem(&ocfs_fs_type);
 	} else
 		return -1;
 }
@@ -434,18 +434,18 @@
 static void __exit ocfs2_exit(void)
 {
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	ocfs_free_mem_caches();
 
 	/* Deinit the proc interface */
-	ocfs_proc_deinit ();
+	ocfs_proc_deinit();
 
-	unregister_filesystem (&ocfs_fs_type);
+	unregister_filesystem(&ocfs_fs_type);
 
 	exit_ocfs2_extent_maps();
 
-	mlog_exit_void ();
+	mlog_exit_void();
 }
 
 
@@ -453,14 +453,14 @@
  * ocfs_put_super()
  *
  */
-static void ocfs_put_super (struct super_block *sb)
+static void ocfs_put_super(struct super_block *sb)
 {
-	mlog_entry ("(0x%p)\n", sb);
+	mlog_entry("(0x%p)\n", sb);
 
 	ocfs_sync_blockdev(sb);
-	ocfs_dismount_volume (sb, 0);
+	ocfs_dismount_volume(sb, 0);
 
-	mlog_exit_void ();
+	mlog_exit_void();
 }				/* ocfs_put_super */
 
 
@@ -478,7 +478,7 @@
 	struct buffer_head *bh = NULL;
 	struct inode *inode = NULL;
 
-	mlog_entry ("(%p, %p)\n", sb, buf);
+	mlog_entry("(%p, %p)\n", sb, buf);
 
 	osb = OCFS2_SB(sb);
 
@@ -519,9 +519,9 @@
 	status = 0;
 bail:
 	if (inode)
-		iput (inode);
+		iput(inode);
 
-	mlog_exit (status);
+	mlog_exit(status);
 
 	return status;
 }                               /* ocfs_statfs */
@@ -599,8 +599,8 @@
 		     hdr->major_version, hdr->minor_version);
 		status = -EINVAL;
 	}
-	if (memcmp (hdr->signature, OCFS1_VOLUME_SIGNATURE,
-		    strlen (OCFS1_VOLUME_SIGNATURE)) == 0) {
+	if (memcmp(hdr->signature, OCFS1_VOLUME_SIGNATURE,
+		   strlen(OCFS1_VOLUME_SIGNATURE)) == 0) {
 		mlog(ML_ERROR, "incompatible volume signature: %8s\n",
 		     hdr->signature);
 		status = -EINVAL;
@@ -688,14 +688,14 @@
  * ocfs_mount_volume()
  *
  */
-static int ocfs_mount_volume (struct super_block *sb)
+static int ocfs_mount_volume(struct super_block *sb)
 {
 	int status, sector_size;
 	int unlock_super = 0;
 	ocfs_super *osb = NULL;
 	struct buffer_head *bh = NULL;
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	/* probe for superblock */
 	status = ocfs2_sb_probe(sb, &bh, &sector_size);
@@ -775,12 +775,12 @@
 	}
 
 	/* Add proc entry for this volume */
-	ocfs_proc_add_volume (osb);
+	ocfs_proc_add_volume(osb);
 
 	/* Read the publish sector for this node and cleanup dirent being */
 	/* modified when we crashed. */
 	mlog(0, "ocfs_check_volume...\n");
-	status = ocfs_check_volume (osb);
+	status = ocfs_check_volume(osb);
 	if (status < 0) {
 		mlog_errno(status);
 		goto leave;
@@ -807,7 +807,7 @@
 
 	if (bh != NULL)
 		brelse(bh);
-	mlog_exit (status);
+	mlog_exit(status);
 	return status;
 }				/* ocfs_mount_volume */
 
@@ -825,12 +825,12 @@
  * ocfs_dismount_volume()
  *
  */
-static void ocfs_dismount_volume (struct super_block *sb, int mnt_err)
+static void ocfs_dismount_volume(struct super_block *sb, int mnt_err)
 {
 	int tmp;
 	ocfs_super *osb = NULL;
 
-	mlog_entry ("(0x%p)\n", sb);
+	mlog_entry("(0x%p)\n", sb);
 
 	OCFS_ASSERT(sb);
 	osb = OCFS2_SB(sb);
@@ -921,7 +921,7 @@
 		ret = snprintf(ptr, 3, "%02X", uuid[i]);
 		if (ret != 2) /* drop super cleans up */
 			return -EINVAL;
-		/* then only advace past the last char */
+		/* then only advance past the last char */
 		ptr += 2;
 	}
 
@@ -941,7 +941,7 @@
 	struct buffer_head *bitmap_bh = NULL;
 	ocfs_journal *journal;
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	INIT_LIST_HEAD(&osb->osb_net_handlers);
 	init_waitqueue_head(&osb->recovery_event);
@@ -972,15 +972,15 @@
 	snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
 		 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
 
-	init_MUTEX (&(osb->recovery_lock));
+	init_MUTEX(&osb->recovery_lock);
 
 	osb->disable_recovery = 0;
 	osb->recovery_thread_task = NULL;
 
-	init_waitqueue_head (&osb->checkpoint_event);
-	atomic_set (&osb->needs_checkpoint, 0);
-	atomic_set (&osb->clean_buffer_seq, 1);
-	spin_lock_init (&osb->clean_buffer_lock);
+	init_waitqueue_head(&osb->checkpoint_event);
+	atomic_set(&osb->needs_checkpoint, 0);
+	atomic_set(&osb->clean_buffer_seq, 1);
+	spin_lock_init(&osb->clean_buffer_lock);
 
 	osb->node_num = OCFS_INVALID_NODE_NUM;
 	osb->slot_num = OCFS_INVALID_NODE_NUM;
@@ -992,12 +992,13 @@
 
 	init_waitqueue_head(&osb->osb_mount_event);
 	
-	osb->vol_label = kmalloc(64, GFP_KERNEL);
+	osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL);
 	if (!osb->vol_label) {
 		mlog(ML_ERROR, "unable to alloc vol label\n");
 		status = -ENOMEM;
 		goto bail;
 	}
+
 	osb->uuid = kmalloc(OCFS2_VOL_UUID_LEN, GFP_KERNEL);
 	if (!osb->uuid) {
 		mlog(ML_ERROR, "unable to alloc uuid\n");
@@ -1076,11 +1077,19 @@
 	journal->j_state = OCFS_JOURNAL_FREE;
 
 	/* get some pseudo constants for clustersize bits */
-	osb->s_clustersize_bits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
+	osb->s_clustersize_bits =
+		le32_to_cpu(di->id2.i_super.s_clustersize_bits);
 	osb->s_clustersize = 1 << osb->s_clustersize_bits;
 	mlog(0, "clusterbits=%d\n", osb->s_clustersize_bits);
-	OCFS_ASSERT(osb->s_clustersize_bits);
 
+	if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE ||
+	    osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) {
+		mlog(ML_ERROR, "Volume has invalid cluster size (%d)\n",
+		     osb->s_clustersize);
+		status = -EINVAL;
+		goto bail;
+	}
+
 	if (ocfs2_clusters_to_blocks(osb->sb, di->i_clusters - 1)
 	    > (u32)~0UL) {
 		mlog(ML_ERROR, "Volume might try to write to blocks beyond "
@@ -1100,14 +1109,15 @@
 	osb->vol_label[63] = '\0';
 	osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno);
 	osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno);
-	osb->first_cluster_group_blkno = le64_to_cpu(di->id2.i_super.s_first_cluster_group);
+	osb->first_cluster_group_blkno =
+		le64_to_cpu(di->id2.i_super.s_first_cluster_group);
 	osb->fs_generation = le32_to_cpu(di->i_fs_generation);
 	mlog(0, "vol_label: %s\n", osb->vol_label);
 	mlog(0, "uuid: %s\n", osb->uuid_str);
 	mlog(0, "root_blkno=%"MLFu64", system_dir_blkno=%"MLFu64"\n",
 	     osb->root_blkno, osb->system_dir_blkno);
 
-	atomic_set (&osb->vol_state, VOLUME_INIT);
+	atomic_set(&osb->vol_state, VOLUME_INIT);
 
 	/* load root, system_dir, and all global system inodes */
 	status = ocfs_init_global_system_inodes(osb);
@@ -1127,8 +1137,9 @@
 	}
 
 	if (inode->i_size >> osb->sb->s_blocksize_bits < OCFS2_MAX_NODES) {
-		mlog(ML_ERROR, "heartbeat area size incorrect: found=%llu, "
-		     "need=%u\n", inode->i_size,
+		mlog(ML_ERROR,
+		     "heartbeat area size incorrect: found=%llu, need=%u\n",
+		     inode->i_size,
 		     OCFS2_MAX_NODES << osb->sb->s_blocksize_bits);
 		status = -EINVAL;
 		goto bail;
@@ -1175,15 +1186,13 @@
 	if (osb_id < OCFS_MAX_OSB_ID)
 		osb_id++;
 	else {
-		spin_unlock (&ocfs2_globals_lock);
 		mlog(ML_ERROR, "Too many volumes mounted\n");
 		status = -ENOMEM;
-		goto bail;
 	}
-	spin_unlock (&ocfs2_globals_lock);
+	spin_unlock(&ocfs2_globals_lock);
 
 bail:
-	mlog_exit (status);
+	mlog_exit(status);
 	return status;
 }				/* ocfs_initialize_osb */
 
@@ -1198,7 +1207,7 @@
 {
 	int status = -EAGAIN;
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
 		   strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
@@ -1241,7 +1250,7 @@
 		}
 	}
 
-	mlog_exit (status);
+	mlog_exit(status);
 	return status;
 }				/* ocfs_verify_volume */
 
@@ -1249,7 +1258,7 @@
  * ocfs_check_volume()
  *
  */
-static int ocfs_check_volume (ocfs_super * osb)
+static int ocfs_check_volume(ocfs_super *osb)
 {
 	int status = 0;
 	int dirty;
@@ -1257,7 +1266,7 @@
 					   * recover
 					   * ourselves. */
 
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	/* Init our journal object. */
 	status = ocfs_journal_init(osb->journal, &dirty);
@@ -1323,7 +1332,7 @@
 	if (local_alloc)
 		kfree(local_alloc);
 
-	mlog_exit (status);
+	mlog_exit(status);
 	return status;
 }				/* ocfs_check_volume */
 
@@ -1336,9 +1345,9 @@
  * It will remove the osb from the global list and also free up all the
  * initialized resources and fileobject.
  */
-static void ocfs_delete_osb (ocfs_super * osb)
+static void ocfs_delete_osb(ocfs_super *osb)
 {
-	mlog_entry_void ();
+	mlog_entry_void();
 
 	/* This function assumes that the caller has the main osb resource */
 
@@ -1354,9 +1363,9 @@
 	if (osb->local_alloc_copy)
 		kfree(osb->local_alloc_copy);
 	kfree(osb->uuid_str);
-	memset (osb, 0, sizeof (ocfs_super));
+	memset(osb, 0, sizeof(ocfs_super));
 
-	mlog_exit_void ();
+	mlog_exit_void();
 }				/* ocfs_delete_osb */
 
 



More information about the Ocfs2-commits mailing list