From a7ae50c6ee8de56afbdae3176a355da54f45b21a Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Thu, 5 Jan 2012 10:39:45 +1300 Subject: [PATCH] yaffs large file support: Fix max file size issue that prevented the scanning working. Right now, yaffs2 large file support seems to be doing everything needed to support large files. Large files are faithfully restored over cache dropping, remounting and rescanning (remount without checkpoint). Signed-off-by: Charles Manning --- yaffs_guts.c | 8 +++++++- yaffs_guts.h | 2 ++ yaffs_vfs_multi.c | 17 ++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/yaffs_guts.c b/yaffs_guts.c index 6166d98..ae37c3f 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -696,6 +696,11 @@ void yaffs_set_obj_name_from_oh(struct yaffs_obj *obj, #endif } +loff_t yaffs_max_file_size(struct yaffs_dev *dev) +{ + return ((loff_t) YAFFS_MAX_CHUNK_ID) * dev->data_bytes_per_chunk; +} + /*-------------------- TNODES ------------------- * List of spare tnodes @@ -1953,7 +1958,8 @@ struct yaffs_obj *yaffs_new_obj(struct yaffs_dev *dev, int number, case YAFFS_OBJECT_TYPE_FILE: the_obj->variant.file_variant.file_size = 0; the_obj->variant.file_variant.scanned_size = 0; - the_obj->variant.file_variant.shrink_size = ~0; /* max */ + the_obj->variant.file_variant.shrink_size = + yaffs_max_file_size(dev); the_obj->variant.file_variant.top_level = 0; the_obj->variant.file_variant.top = tn; break; diff --git a/yaffs_guts.h b/yaffs_guts.h index 72e86a8..6e48d13 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -960,5 +960,7 @@ void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr, */ void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize); loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh); +loff_t yaffs_max_file_size(struct yaffs_dev *dev); + #endif diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index 70ddce9..8f6e4b5 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -970,13 +970,14 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg) struct yaffs_obj *obj; unsigned char *pg_buf; int ret; + loff_t pos = ((loff_t) pg->index) << PAGE_CACHE_SHIFT; struct yaffs_dev *dev; yaffs_trace(YAFFS_TRACE_OS, - "yaffs_readpage_nolock at %08x, size %08x", - (unsigned)(pg->index << PAGE_CACHE_SHIFT), - (unsigned)PAGE_CACHE_SIZE); + "yaffs_readpage_nolock at %lld, size %08x", + (long long)pos, + (unsigned)PAGE_CACHE_SIZE); obj = yaffs_dentry_to_obj(f->f_dentry); @@ -994,8 +995,7 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg) yaffs_gross_lock(dev); - ret = yaffs_file_rd(obj, pg_buf, - pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE); + ret = yaffs_file_rd(obj, pg_buf, pos, PAGE_CACHE_SIZE); yaffs_gross_unlock(dev); @@ -1101,7 +1101,7 @@ static int yaffs_writepage(struct page *page) obj->variant.file_variant.file_size, inode->i_size); n_written = yaffs_wr_file(obj, buffer, - page->index << PAGE_CACHE_SHIFT, n_bytes, 0); + ((loff_t)page->index) << PAGE_CACHE_SHIFT, n_bytes, 0); yaffs_touch_super(dev); @@ -2815,7 +2815,6 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, sb->u.generic_sbp = dev; #endif - sb->s_maxbytes = 35000000000LL; dev->driver_context = mtd; param->name = mtd->name; @@ -2938,6 +2937,8 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, if (!context->bg_thread) param->defered_dir_update = 0; + sb->s_maxbytes = yaffs_max_file_size(dev); + /* Release lock before yaffs_get_inode() */ yaffs_gross_unlock(dev); @@ -3114,6 +3115,8 @@ static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev) static char *yaffs_dump_dev_part1(char *buf, struct yaffs_dev *dev) { + buf += sprintf(buf, "max file size....... %lld\n", + (long long) yaffs_max_file_size(dev)); buf += sprintf(buf, "data_bytes_per_chunk. %d\n", dev->data_bytes_per_chunk); buf += sprintf(buf, "chunk_grp_bits....... %d\n", dev->chunk_grp_bits); -- 2.30.2