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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Mar 30 18:31:35 CST 2005


Author: manish
Signed-off-by: jlbec
Signed-off-by: mfasheh
Date: 2005-03-30 18:31:33 -0600 (Wed, 30 Mar 2005)
New Revision: 2092

Modified:
   trunk/fs/ocfs2/super.c
Log:
Calculate s_maxbytes the same way xfs does, instead of hardcoding it

Signed-off-by: jlbec
Signed-off-by: mfasheh


Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-03-31 00:23:25 UTC (rev 2091)
+++ trunk/fs/ocfs2/super.c	2005-03-31 00:31:33 UTC (rev 2092)
@@ -68,8 +68,6 @@
 
 #include "buffer_head_io.h"
 
-#define OCFS_LINUX_MAX_FILE_SIZE	9223372036854775807LL
-
 #define OCFS_DEBUG_CONTEXT  OCFS_DEBUG_CONTEXT_SUPER
 
 /*
@@ -156,6 +154,8 @@
 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 unsigned long long ocfs2_max_file_offset(unsigned int blockshift);
+
 static struct super_operations ocfs_sops = {
 	.statfs = ocfs_statfs,
 	.clear_inode = ocfs_clear_inode,
@@ -304,6 +304,41 @@
 	return status;
 } /* ocfs_release_system_inodes */
 
+/* From xfs_super.c:xfs_max_file_offset
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.
+ */
+static unsigned long long ocfs2_max_file_offset(unsigned int blockshift)
+{
+	unsigned int pagefactor = 1;
+	unsigned int bitshift = BITS_PER_LONG - 1;
+
+	/* Figure out maximum filesize, on Linux this can depend on
+	 * the filesystem blocksize (on 32 bit platforms).
+	 * __block_prepare_write does this in an [unsigned] long...
+	 *      page->index << (PAGE_CACHE_SHIFT - bbits)
+	 * So, for page sized blocks (4K on 32 bit platforms),
+	 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
+	 *      (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
+	 * but for smaller blocksizes it is less (bbits = log2 bsize).
+	 * Note1: get_block_t takes a long (implicit cast from above)
+	 * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
+	 * can optionally convert the [unsigned] long from above into
+	 * an [unsigned] long long.
+	 */
+
+#if BITS_PER_LONG == 32
+# if defined(CONFIG_LBD)
+	OCFS_ASSERT(sizeof(sector_t) == 8);
+	pagefactor = PAGE_CACHE_SIZE;
+	bitshift = BITS_PER_LONG;
+# else
+	pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
+# endif
+#endif
+
+	return (((unsigned long long)pagefactor) << bitshift) - 1;
+}
+
 static int ocfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct dentry *root;
@@ -333,13 +368,13 @@
 	sb->s_op = &ocfs_sops;
 	sb->s_flags |= MS_NOATIME;
 
-	/* this is needed to support O_LARGEFILE */
-	sb->s_maxbytes = OCFS_LINUX_MAX_FILE_SIZE;
-
 	status = ocfs_mount_volume (sb, reclaim_id, NULL);
 	if (status < 0)
 		goto read_super_error;
 
+	/* this is needed to support O_LARGEFILE */
+	sb->s_maxbytes = ocfs2_max_file_offset(sb->s_blocksize_bits);
+
 	osb = OCFS_SB(sb);
 	if (!osb) {
 		status = -EINVAL;



More information about the Ocfs2-commits mailing list