aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/super.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-11 19:01:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-11 19:01:34 -0400
commit886c81834884ed3df0d8cfc613d65441226786c8 (patch)
treed3f6358a94e99bdc8d29acffe461d2ad33812057 /fs/ocfs2/super.c
parentdc8a7b11aa68d6795a46e0a42ce92220d1a6f0cd (diff)
parente0dceaf0a4b8c55076a4dbcba7ac8b05755f5cc6 (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2: ocfs2: set non-default s_time_gran during mount ocfs2: Retry sendpage() if it returns EAGAIN ocfs2: Fix rename/extend race [2.6 patch] ocfs2_insert_extent(): remove dead code ocfs2: Fix max offset calculations ocfs2: check ia_size limits in setattr ocfs2: Fix some casting errors related to file writes ocfs2: use s_maxbytes directly in ocfs2_change_file_space() ocfs2: Restrict inode changes in ocfs2_update_inode_atime()
Diffstat (limited to 'fs/ocfs2/super.c')
-rw-r--r--fs/ocfs2/super.c69
1 files changed, 41 insertions, 28 deletions
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 200c7d4790dc..f2fc9a795deb 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -316,39 +316,51 @@ static void ocfs2_destroy_inode(struct inode *inode)
316 kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); 316 kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode));
317} 317}
318 318
319/* From xfs_super.c:xfs_max_file_offset 319static unsigned long long ocfs2_max_file_offset(unsigned int bbits,
320 * Copyright (c) 2000-2004 Silicon Graphics, Inc. 320 unsigned int cbits)
321 */
322unsigned long long ocfs2_max_file_offset(unsigned int blockshift)
323{ 321{
324 unsigned int pagefactor = 1; 322 unsigned int bytes = 1 << cbits;
325 unsigned int bitshift = BITS_PER_LONG - 1; 323 unsigned int trim = bytes;
326 324 unsigned int bitshift = 32;
327 /* Figure out maximum filesize, on Linux this can depend on 325
328 * the filesystem blocksize (on 32 bit platforms). 326 /*
329 * __block_prepare_write does this in an [unsigned] long... 327 * i_size and all block offsets in ocfs2 are always 64 bits
330 * page->index << (PAGE_CACHE_SHIFT - bbits) 328 * wide. i_clusters is 32 bits, in cluster-sized units. So on
331 * So, for page sized blocks (4K on 32 bit platforms), 329 * 64 bit platforms, cluster size will be the limiting factor.
332 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
333 * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
334 * but for smaller blocksizes it is less (bbits = log2 bsize).
335 * Note1: get_block_t takes a long (implicit cast from above)
336 * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
337 * can optionally convert the [unsigned] long from above into
338 * an [unsigned] long long.
339 */ 330 */
340 331
341#if BITS_PER_LONG == 32 332#if BITS_PER_LONG == 32
342# if defined(CONFIG_LBD) 333# if defined(CONFIG_LBD)
343 BUILD_BUG_ON(sizeof(sector_t) != 8); 334 BUILD_BUG_ON(sizeof(sector_t) != 8);
344 pagefactor = PAGE_CACHE_SIZE; 335 /*
345 bitshift = BITS_PER_LONG; 336 * We might be limited by page cache size.
337 */
338 if (bytes > PAGE_CACHE_SIZE) {
339 bytes = PAGE_CACHE_SIZE;
340 trim = 1;
341 /*
342 * Shift by 31 here so that we don't get larger than
343 * MAX_LFS_FILESIZE
344 */
345 bitshift = 31;
346 }
346# else 347# else
347 pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift); 348 /*
349 * We are limited by the size of sector_t. Use block size, as
350 * that's what we expose to the VFS.
351 */
352 bytes = 1 << bbits;
353 trim = 1;
354 bitshift = 31;
348# endif 355# endif
349#endif 356#endif
350 357
351 return (((unsigned long long)pagefactor) << bitshift) - 1; 358 /*
359 * Trim by a whole cluster when we can actually approach the
360 * on-disk limits. Otherwise we can overflow i_clusters when
361 * an extent start is at the max offset.
362 */
363 return (((unsigned long long)bytes) << bitshift) - trim;
352} 364}
353 365
354static int ocfs2_remount(struct super_block *sb, int *flags, char *data) 366static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
@@ -1259,8 +1271,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1259 int sector_size) 1271 int sector_size)
1260{ 1272{
1261 int status = 0; 1273 int status = 0;
1262 int i; 1274 int i, cbits, bbits;
1263 struct ocfs2_dinode *di = NULL; 1275 struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
1264 struct inode *inode = NULL; 1276 struct inode *inode = NULL;
1265 struct buffer_head *bitmap_bh = NULL; 1277 struct buffer_head *bitmap_bh = NULL;
1266 struct ocfs2_journal *journal; 1278 struct ocfs2_journal *journal;
@@ -1279,9 +1291,12 @@ static int ocfs2_initialize_super(struct super_block *sb,
1279 sb->s_fs_info = osb; 1291 sb->s_fs_info = osb;
1280 sb->s_op = &ocfs2_sops; 1292 sb->s_op = &ocfs2_sops;
1281 sb->s_export_op = &ocfs2_export_ops; 1293 sb->s_export_op = &ocfs2_export_ops;
1294 sb->s_time_gran = 1;
1282 sb->s_flags |= MS_NOATIME; 1295 sb->s_flags |= MS_NOATIME;
1283 /* this is needed to support O_LARGEFILE */ 1296 /* this is needed to support O_LARGEFILE */
1284 sb->s_maxbytes = ocfs2_max_file_offset(sb->s_blocksize_bits); 1297 cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
1298 bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
1299 sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
1285 1300
1286 osb->sb = sb; 1301 osb->sb = sb;
1287 /* Save off for ocfs2_rw_direct */ 1302 /* Save off for ocfs2_rw_direct */
@@ -1341,8 +1356,6 @@ static int ocfs2_initialize_super(struct super_block *sb,
1341 goto bail; 1356 goto bail;
1342 } 1357 }
1343 1358
1344 di = (struct ocfs2_dinode *)bh->b_data;
1345
1346 osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots); 1359 osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots);
1347 if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) { 1360 if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) {
1348 mlog(ML_ERROR, "Invalid number of node slots (%u)\n", 1361 mlog(ML_ERROR, "Invalid number of node slots (%u)\n",