[Ocfs2-commits] jlbec commits r1087 - branches/format-changes/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jun 14 02:52:30 CDT 2004


Author: jlbec
Date: 2004-06-14 01:52:28 -0500 (Mon, 14 Jun 2004)
New Revision: 1087

Modified:
   branches/format-changes/src/hash.c
   branches/format-changes/src/inode.c
   branches/format-changes/src/ocfs.h
   branches/format-changes/src/ocfs2_fs.h
   branches/format-changes/src/proc.c
   branches/format-changes/src/super.c
   branches/format-changes/src/volcfg.c
Log:

o Get sector_size in sb_probe and add it to the osb
o Fix ocfs_rw_* for blocksize work.
o Fix symlink_get_block for s_blocksize.



Modified: branches/format-changes/src/hash.c
===================================================================
--- branches/format-changes/src/hash.c	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/hash.c	2004-06-14 06:52:28 UTC (rev 1087)
@@ -599,7 +599,7 @@
 		} else {
 			do_timeout = 0;
 			set_task_state(tsk, TASK_INTERRUPTIBLE);
-			io_schedule_timeout(BUFFER_MODIFIED_TIMEOUT);
+			schedule_timeout(BUFFER_MODIFIED_TIMEOUT);
 			if (buffer_modified(bh) && 
 			    sem->s_pid != current->pid && sem->s_pid != 0) {
 #ifdef BH_SEM_DEBUG

Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/inode.c	2004-06-14 06:52:28 UTC (rev 1087)
@@ -951,7 +951,6 @@
 static int ocfs_symlink_get_block (struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
 {
 	int err = -EIO;
-	ocfs_super *osb;
 	int status;
 	ocfs2_dinode *fe = NULL;
 	__u64 entryOffset;
@@ -965,10 +964,7 @@
 		goto bail;
 	}
 
-	osb = OCFS_SB(inode->i_sb);
-
-#warning This really needs blocksize fixup
-	if ((iblock << 9) > PATH_MAX + 1) {
+	if ((iblock << inode->i_sb->s_blocksize_bits) > PATH_MAX + 1) {
 		LOG_ERROR_ARGS ("file offset > PATH_MAX: %llu",
 				(unsigned long long)iblock << 9);
 		goto bail;
@@ -976,21 +972,22 @@
 
 	entryOffset = GET_INODE_FEOFF(inode);
 
-	status = ocfs_read_bh (osb, entryOffset, &bh, OCFS_BH_CACHED, inode);
+	status = ocfs_read_bh(OCFS_SB(inode->i_sb), entryOffset, &bh,
+			      OCFS_BH_CACHED, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto bail;
 	}
 	fe = OCFS_BH_GET_DATA_READ(bh);
 
-	if (!IS_VALID_FILE_ENTRY (fe)) {
+	if (!IS_VALID_FILE_ENTRY(fe)) {
 		OCFS_BH_PUT_DATA(bh);
 		LOG_ERROR_ARGS ("Invalid fe at offset %llu", entryOffset);
 		goto bail;
 	}
 
-	if ((iblock << 9) >=
-	    (__s64)((u64)fe->i_clusters << osb->s_clustersize_bits)) {
+	if ((u64)iblock >= ocfs_clusters_to_blocks(inode->i_sb,
+					      fe->i_clusters)) {
 		OCFS_BH_PUT_DATA(bh);
 		LOG_ERROR_ARGS ("file offset is outside the allocated size: %llu",
 		     (unsigned long long)iblock << 9);
@@ -1515,7 +1512,7 @@
 	struct inode *inode = filp->f_dentry->d_inode;
 	int max_sectors;
 	int nbhs;
-	int sector_size, sector_bits, sector_mask;
+	int sector_size, sector_bits, sector_mask, sectors_per_page;
 	int ret = 0;
 	int large_io = 0;
 	int inuse = 0;
@@ -1532,9 +1529,10 @@
 	saved_size = size;
 	
 	/* FIXME: Need to differentiate between sectors and blocksize */
-	sector_size = 512;
-	sector_bits = 9;
-	sector_mask = 511;
+	sector_bits = OCFS_SB(inode->i_sb)->s_sectsize_bits;
+	sector_size = 1 << OCFS_SB(inode->i_sb)->s_sectsize_bits;
+	sector_mask = sector_size - 1;
+	sectors_per_page = PAGE_SIZE / sector_size;
 	/* max sectors is 1024 in 2.4.9
 	 * max data is 512kb  
 	 */
@@ -1552,7 +1550,7 @@
 	      size = inode->i_size - *offp;
 	}
 
-	/* make sure we are aligned to either 4kb or 512 byte IO */
+	/* make sure aligned to either PAGE_SIZE or sect_size IO */
 #ifndef LARGEIOS
 	if ((*offp & sector_mask) || (size & sector_mask))
 	   /* if not, then fail, we need either to do dio */
@@ -1562,19 +1560,19 @@
 	large_io = 0;
 #endif
 #ifdef LARGEIOS	
-	if ((*offp & 4095) || (size & 4095)) {
-		/* if it's not 4kb, then 512 */
+	if ((*offp & ~PAGE_MASK) || (size & ~PAGE_MASK)) {
+		/* if it's not PAGE_SIZE, then sect_size */
 		 if ((*offp & sector_mask) || (size & sector_mask))
 			 /* if not, then fail, we need either to do dio */
 			 return err;
 		 max_sectors = KIO_MAX_SECTORS; /* for 2.4.9 - 1024 */
-	} /* ok we 're 4kb aligned, lets see if the buffer is */
+	} /* ok we 're PAGE_SIZE aligned, lets see if the buffer is */
 	else {
-		if (!((unsigned long) buf & 4095)) {
-			/* yippie we are .. we can do 4kb size io's */
+		if (!((unsigned long) buf & ~PAGE_MASK)) {
+			/* yippie we are .. we can do PAGE_SIZE size io's */
 			large_io = 1;
 			/* for 2.4.9 */
-			max_sectors = KIO_MAX_SECTORS / 8;
+			max_sectors = KIO_MAX_SECTORS / sectors_per_page;
 		} else {
 			max_sectors = KIO_MAX_SECTORS;
 			large_io = 0;
@@ -1636,7 +1634,7 @@
 doio:
 		size = totalioblocks << sector_bits;
 		if (large_io)
-			nbhs = (size >> 12);
+			nbhs = (size >> PAGE_SHIFT);
 		else
 			nbhs = (size >> sector_bits);
 		if (nbhs > max_sectors)
@@ -1665,10 +1663,10 @@
 		totalioblocks = 0;
 		while (size > 0) {
 			if (large_io) {
-				blocks = size >> 12;
+				blocks = size >> PAGE_SHIFT;
 				if (blocks > max_sectors)
 					blocks = max_sectors;
-				iosize = blocks << 12;
+				iosize = blocks << PAGE_SHIFT;
 			} else {
 				blocks = size >> sector_bits;
 				if (blocks > max_sectors)
@@ -1685,22 +1683,22 @@
 			OCFS_KIO_BLOCKS(iobuf)[0] = firstphys + totalioblocks;
 
 			if (large_io) {
-				blocknr+=8;
-				OCFS_KIO_BLOCKS(iobuf)[0] = OCFS_KIO_BLOCKS(iobuf)[0] / 8;
+				blocknr += sectors_per_page;
+				OCFS_KIO_BLOCKS(iobuf)[0] = OCFS_KIO_BLOCKS(iobuf)[0] / sectors_per_page;
 			} else {
 				blocknr++;
 			}
 
 			for (i = 1; i < blocks; i++) {
 				if (large_io) {
-					blocknr+=8;
+					blocknr += sectors_per_page;
 				} else {
 					blocknr++;
 				}
 				OCFS_KIO_BLOCKS(iobuf)[i] = OCFS_KIO_BLOCKS(iobuf)[0] + i;
 			}
 			err = brw_kiovec (rw, 1, &iobuf, inode->i_dev, OCFS_KIO_BLOCKS(iobuf),
-					large_io ? 4096 : sector_size);
+					large_io ? PAGE_SIZE : sector_size);
 #ifdef SUSE
 			if (rw == READ &&  err > 0)
 				mark_dirty_kiobuf(iobuf, err);
@@ -1710,7 +1708,8 @@
 				size -= err;
 				buf += err;
 				if (large_io) {
-					totalioblocks += (blocks * 8);
+					totalioblocks +=
+					    (blocks * sectors_per_page);
 				} else {
 					totalioblocks += blocks;
 				}
@@ -1769,7 +1768,7 @@
 
 int ocfs_kvec_rw(struct file *filp, int rw, kvec_cb_t cb, size_t size, loff_t pos) 
 {
-	int             err = 0;
+	int	     err = 0;
 	int max_sectors = 25000;
 	struct inode *inode = filp->f_dentry->d_inode;
 	unsigned long blocknr, blocks, iosize,myiosize;
@@ -1778,9 +1777,9 @@
 	unsigned long blocks_end_cluster = 0;
  
 	/* FIXME: Need to differentiate betwen sectors and blocksize */
-	int sector_bits = 9;
-	int sector_size = 512;
-	int sector_mask = 511;
+	int sector_bits = OCFS_SB(inode->i_sb)->sect_size_bits;
+	int sector_size = OCFS_SB(inode->i_sb)->sect_size;
+	int sector_mask = sector_size - 1;
 
 	int ret;
 	unsigned long firstlogic;
@@ -1816,7 +1815,7 @@
 	iosize = blocks << sector_bits;
 	clustersize = inode->i_blksize >> sector_bits;
 	blocks_end_cluster = clustersize - (blocknr % clustersize);
-	myiosize = size >> 9;
+	myiosize = size >> sector_bits;
 	firstlogic = blocknr;
 	totalioblocks = 0;
 

Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/ocfs.h	2004-06-14 06:52:28 UTC (rev 1087)
@@ -837,6 +837,7 @@
 	u32 node_num;
 	int reclaim_id;		/* reclaim the original node number*/
 	__u32 hbt;
+	int s_sectsize_bits;
 	int s_clustersize;
 	int s_clustersize_bits;
 	int needs_flush;
@@ -987,73 +988,6 @@
 	__u8 ov_pad[7]; 		// UNUSED
 } ocfs_vote;				// END CLASS
 
-#if 0
-/*
- * On disk file entry (inode) for OCFS v2
- */
-typedef struct _ocfs2_dinode {
-/*00*/	__u8 i_signature[8];		/* Signature for validation */
-	__u32 i_generation;		/* Generation number */
-	__u32 i_suballoc_node;		/* Node suballocater this inode
-					   belongs to */
-/*10*/	__u64 i_suballoc_blkno;		/* Node suballocator offset
-       					   (in blocks) */
-/*18*/	ocfs_disk_lock disk_lock;	/* Lock structure */
-/*38*/	__u32 i_uid;			/* Owner UID */
-	__u32 i_gid;			/* Owning GID */
-/*40*/	__u64 i_size;			/* Size in bytes */
-	__u16 i_mode;			/* File mode */
-	__u16 i_links_count;		/* Links count */
-	__u32 i_flags;			/* File flags */
-/*50*/	__u64 i_atime;			/* Access time */
-	__u64 i_ctime;			/* Creation time */
-/*60*/	__u64 i_mtime;			/* Modification time */
-	__u64 i_dtime;			/* Deletion time */
-/*70*/	__u64 i_blkno;			/* Offset on disk, in blocks */
-	__u32 i_clusters;		/* Cluster count */
-	__u32 i_reserved1;
-
-/*80*/	union {
-		__u64 fe_private;
-                __u64 i_rdev;
-		struct _bitinfo {
-			__u32 used_bits;
-			__u32 total_bits;
-		} bitinfo;
-	} u;
-/*98*/	__s16 i_tree_depth;		/* Extent tree depth
-					 * -1 means data extents hang
-					 * directly off of the
-					 * file_entry.
-					 */
-	__u16 i_next_free_ext;		/* Next unused extent slot */
-	__u32 i_reserved3;
-/*A0*/	__u64 last_ext_ptr;		/* Pointer to last extdat */
-
-/*A8*/  union {
-		struct _superinfo {
-			__u16 major_rev_level;
-			__u16 minor_rev_level;
-			__u16 mnt_count;
-			__s16 max_mnt_count;
-			__u16 state;                /* File system state */
-			__u16 errors;               /* Behaviour when detecting errors */
-			__u32 checkinterval;        /* max. time between checks */
-			__u64 lastcheck;            /* time of last check */
-			__u32 creator_os;  	    /* OS */
-			__u32 feature_compat;       /* compatible feature set */
-			__u32 feature_incompat;     /* incompatible feature set */
-			__u32 feature_ro_compat;    /* readonly-compatible feature set */
-			__u64 root_blkno;	    /* block offset to root directory dinode */
-			__u64 system_dir_blkno;	    /* block offset to system directory dinode */
-			__u8  label[64];	    /* label for mounting, etc. */
-			__u8  uuid[16];    	    /* was vol_id */
-		} super;
-		ocfs_extent_rec extents[OCFS_MAX_FILE_ENTRY_EXTENTS];  // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
-	} u2;
-} ocfs2_dinode;
-#endif
-
 typedef struct _ocfs_dlm_msg_hdr
 {
 	__u64 lock_id;

Modified: branches/format-changes/src/ocfs2_fs.h
===================================================================
--- branches/format-changes/src/ocfs2_fs.h	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/ocfs2_fs.h	2004-06-14 06:52:28 UTC (rev 1087)
@@ -182,11 +182,11 @@
 #define OCFS2_NODE_MIN_SUPPORTED_VER	2
 
 #define MAX_IP_ADDR_LEN		32
-#define HOSTID_LEN              20
-#define MACID_LEN		12
-#define GUID_LEN		(HOSTID_LEN+MACID_LEN)
 #define MAX_NODE_NAME_LENGTH	32
 
+#define OCFS2_GUID_HOSTID_LEN	20
+#define OCFS2_GUID_MACID_LEN	12
+#define OCFS2_GUID_LEN		(OCFS2_GUID_HOSTID_LEN + OCFS2_GUID_MACID_LEN)
 
 
 
@@ -377,17 +377,17 @@
 	__u8 ip_mask[MAX_IP_ADDR_LEN+1];		// CHAR[MAX_IP_ADDR_LEN+1]
 }
 ocfs_ipc_config_info;	// END CLASS
+
 /* TODO this structure will break in 64-bit.... need to pack */
-typedef union _ocfs_guid				// CLASS
+typedef union _ocfs_guid
 {
 	struct
 	{
-		char host_id[HOSTID_LEN];
-		char mac_id[MACID_LEN];
+		char host_id[OCFS2_GUID_HOSTID_LEN];
+		char mac_id[OCFS2_GUID_MACID_LEN];
 	} id;
-	__u8 guid[GUID_LEN];				// CHAR[GUID_LEN]
-}
-ocfs_guid;						// END CLASS
+	__u8 guid[OCFS2_GUID_LEN];
+} ocfs_guid;
 
 typedef struct _ocfs_node_config_info			// CLASS
 {

Modified: branches/format-changes/src/proc.c
===================================================================
--- branches/format-changes/src/proc.c	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/proc.c	2004-06-14 06:52:28 UTC (rev 1087)
@@ -156,8 +156,8 @@
 		       	OcfsGlobalCtxt.comm_info.ip_addr,
 		       	OcfsGlobalCtxt.comm_info.ip_port);
 	len += sprintf (page + len, "guid         : ");
-	strncat (page + len, OcfsGlobalCtxt.guid.guid, GUID_LEN);
-	len += GUID_LEN;
+	strncat (page + len, OcfsGlobalCtxt.guid.guid, OCFS2_GUID_LEN);
+	len += OCFS2_GUID_LEN;
 	strncat (page + len, "\n", 1);
 	len++;
 
@@ -580,8 +580,9 @@
 				       	i, mount, node->node_name,
 				       	node->ipc_config.ip_addr,
 				       	node->ipc_config.ip_port);
-			strncat (page + len, node->guid.guid, GUID_LEN);
-			len += GUID_LEN;
+			strncat(page + len, node->guid.guid,
+		       		OCFS2_GUID_LEN);
+			len += OCFS2_GUID_LEN;
 			len += sprintf (page + len, "\n");
 		}
 		up (&(osb->cfg_lock));

Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/super.c	2004-06-14 06:52:28 UTC (rev 1087)
@@ -645,8 +645,8 @@
 		LOG_ERROR_STR ("'ip_address' not set or too long");
 	}
 
-	if (guid && strlen (guid) == GUID_LEN) {
-		memcpy (&OcfsGlobalCtxt.guid.guid, guid, GUID_LEN);
+	if (guid && strlen (guid) == OCFS2_GUID_LEN) {
+		memcpy(&OcfsGlobalCtxt.guid.guid, guid, OCFS2_GUID_LEN);
 		LOG_TRACE_ARGS ("Node guid: %s\n", guid);
 	} else {
 		status = -EINVAL;
@@ -654,7 +654,7 @@
 	}
 
 	if (status == 0) {
-		for (i = 0; i < GUID_LEN; ++i)
+		for (i = 0; i < OCFS2_GUID_LEN; ++i)
 			check_sum += (__u32) guid[i];
 		if (cs != check_sum) {
 			status = -EINVAL;
@@ -853,25 +853,27 @@
 }
 #endif /* 2.6.0 */
 
-static int ocfs2_sb_probe(struct super_block *sb, struct buffer_head **bh)
+static int ocfs2_sb_probe(struct super_block *sb,
+			  struct buffer_head **bh, 
+			  int *sector_size)
 {
 	int status = 0, tmpstat;
 	ocfs1_vol_disk_hdr *hdr;
 	ocfs2_dinode *di;
-	int hardsect, sectsize;
+	int blksize;
 
 	*bh = NULL;
 
 	/* may be > 512 */
-	hardsect = ocfs_hardsect_size(OCFS_GET_BLOCKDEV(sb));
-	if (hardsect > 4096) {
-		LOG_ERROR_ARGS("hardsect size too large: %d (max=4096)\n", hardsect);
+	*sector_size = ocfs_hardsect_size(OCFS_GET_BLOCKDEV(sb));
+	if (*sector_size > 4096) {
+		LOG_ERROR_ARGS("Hardware sector size too large: %d (max=4096)\n", *sector_size);
 		status = -EINVAL;
 		goto bail;
 	}
 	
 	/* check block zero for old format */
-	status = ocfs2_get_sector(sb, bh, 0, hardsect);
+	status = ocfs2_get_sector(sb, bh, 0, *sector_size);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
@@ -903,16 +905,16 @@
 	 * the minimum clustersize.
 	 */
 	status = -EINVAL;
-	for (sectsize = hardsect; sectsize <= OCFS2_MAX_BLOCKSIZE; sectsize <<= 1) {
+	for (blksize = *sector_size; blksize <= OCFS2_MAX_BLOCKSIZE; blksize <<= 1) {
 		tmpstat = ocfs2_get_sector(sb, bh, 
 					   OCFS2_SUPER_BLOCK_BLKNO, 
-					   sectsize);
+					   blksize);
 		if (tmpstat < 0) {
 			LOG_ERROR_STATUS(status = tmpstat);
 			goto bail;
 		}
 		di = (ocfs2_dinode *) OCFS_BH_GET_DATA_READ(*bh);
-		status = ocfs_verify_volume(di, *bh, sectsize);
+		status = ocfs_verify_volume(di, *bh, blksize);
 		OCFS_BH_PUT_DATA(*bh);
 		if (status >= 0)
 			goto bail;
@@ -970,11 +972,12 @@
 	ocfs_super *osb;
 	int child_pid;
 	struct buffer_head *bh = NULL;
+	int sector_size;
 
 	LOG_ENTRY ();
 
 	/* probe for superblock */
-	status = ocfs2_sb_probe(sb, &bh);
+	status = ocfs2_sb_probe(sb, &bh, &sector_size);
 	if (status < 0) {
 		LOG_ERROR_STR("superblock probe failed!");
 		goto leave;
@@ -990,6 +993,11 @@
 
 	osb->sb = sb;
 
+	/* Save off for ocfs_rw_direct */
+	osb->s_sectsize_bits = ocfs_get_right_shift_bits(sector_size);
+	if (!osb->s_sectsize_bits)
+		BUG();
+
 	osb->reclaim_id = reclaim_id;
 
 	/* s_blocksize was set in the probe */

Modified: branches/format-changes/src/volcfg.c
===================================================================
--- branches/format-changes/src/volcfg.c	2004-06-14 02:14:41 UTC (rev 1086)
+++ branches/format-changes/src/volcfg.c	2004-06-14 06:52:28 UTC (rev 1087)
@@ -604,7 +604,7 @@
 
 	strncpy ((*node)->node_name, disk->node_name, MAX_NODE_NAME_LENGTH);
 
-	memcpy((*node)->guid.guid, disk->guid.guid, GUID_LEN);
+	memcpy((*node)->guid.guid, disk->guid.guid, OCFS2_GUID_LEN);
 
 	(*node)->ipc_config.type = disk->ipc_config.type;
 	(*node)->ipc_config.ip_port = disk->ipc_config.ip_port;
@@ -685,7 +685,8 @@
 		strncpy (disk->node_name, OcfsGlobalCtxt.node_name,
 			 MAX_NODE_NAME_LENGTH);
 
-	memcpy(disk->guid.guid, OcfsGlobalCtxt.guid.guid, GUID_LEN);
+	memcpy(disk->guid.guid, OcfsGlobalCtxt.guid.guid,
+	       OCFS2_GUID_LEN);
 
 	ipc->type = g_ipc->type;
 	ipc->ip_port = g_ipc->ip_port;
@@ -716,7 +717,8 @@
 		strncpy (node->node_name, OcfsGlobalCtxt.node_name,
 			 MAX_NODE_NAME_LENGTH);
 
-	memcpy(node->guid.guid, OcfsGlobalCtxt.guid.guid, GUID_LEN);
+	memcpy(node->guid.guid, OcfsGlobalCtxt.guid.guid,
+	       OCFS2_GUID_LEN);
 
 	ipc->type = g_ipc->type;
 	ipc->ip_port = g_ipc->ip_port;
@@ -823,14 +825,15 @@
 		 * the volume with the reclaimid option. Else, error.
 		 */
 		if (!memcmp(&OcfsGlobalCtxt.guid.guid, disk->guid.guid,
-			    GUID_LEN)) {
+			    OCFS2_GUID_LEN)) {
 			osb->node_num = i;
 			goto loop;
 		}
 
 		/* If the hostid does not match, goto next... */
 		if (memcmp(&OcfsGlobalCtxt.guid.id.host_id,
-			   disk->guid.id.host_id, HOSTID_LEN))
+			   disk->guid.id.host_id,
+			   OCFS2_GUID_HOSTID_LEN))
 			goto loop;
 
 		/* ...else allow node to reclaim the number if reclaimid set */



More information about the Ocfs2-commits mailing list