bk://linux-ntfs.bkbits.net/ntfs-2.6-devel ntfs@flatcap.org|ChangeSet|20041118013807|25440 ntfs # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/11/17 15:46:56+00:00 aia21@cantab.net # NTFS: Use i_size_read() in fs/ntfs/file.c::ntfs_file_open(). # # Signed-off-by: Anton Altaparmakov # # fs/ntfs/ChangeLog # 2004/11/17 15:45:08+00:00 aia21@cantab.net +1 -0 # Update # # fs/ntfs/file.c # 2004/11/17 15:44:09+00:00 aia21@cantab.net +1 -1 # Use i_size_read() in ntfs_file_open(). # # ChangeSet # 2004/11/11 12:42:47+00:00 aia21@cantab.net # NTFS: Use i_size_read() once and then use the cached value in # fs/ntfs/lcnalloc.c::ntfs_cluster_alloc(). # # Signed-off-by: Anton Altaparmakov # # fs/ntfs/lcnalloc.c # 2004/11/11 12:42:38+00:00 aia21@cantab.net +5 -3 # Use i_size_read() once and then use the cached value in ntfs_cluster_alloc(). # # fs/ntfs/ChangeLog # 2004/11/11 12:42:38+00:00 aia21@cantab.net +2 -0 # Update # # ChangeSet # 2004/11/11 12:34:10+00:00 aia21@cantab.net # NTFS: Use i_size_read() in fs/ntfs/logfile.c::ntfs_{check,empty}_logfile(). # # Signed-off-by: Anton Altaparmakov # # fs/ntfs/logfile.c # 2004/11/11 12:34:01+00:00 aia21@cantab.net +3 -2 # Use i_size_read() when accessing the $LogFile inode->i_size in # ntfs_check_logfile() and ntfs_empty_logfile(). # # fs/ntfs/ChangeLog # 2004/11/11 12:34:00+00:00 aia21@cantab.net +12 -13 # Update # # ChangeSet # 2004/11/11 11:18:20+00:00 aia21@cantab.net # NTFS: Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set(). # # Signed-off-by: Anton Altaparmakov # # fs/ntfs/attrib.c # 2004/11/11 11:18:10+00:00 aia21@cantab.net +5 -1 # Use i_size_read() in ntfs_attr_set(). # # fs/ntfs/Makefile # 2004/11/11 11:18:10+00:00 aia21@cantab.net +1 -1 # Start 2.1.23-WIP. # # fs/ntfs/ChangeLog # 2004/11/11 11:18:10+00:00 aia21@cantab.net +4 -0 # Update # diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog --- a/fs/ntfs/ChangeLog 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/ChangeLog 2004-11-17 19:45:14 -08:00 @@ -2,20 +2,18 @@ - Find and fix bugs. - Checkpoint or disable the user space journal ($UsnJrnl). - In between ntfs_prepare/commit_write, need exclusion between - simultaneous file extensions. Need perhaps an NInoResizeUnderway() - flag which we can set in ntfs_prepare_write() and clear again in - ntfs_commit_write(). Just have to be careful in readpage/writepage, - as well as in truncate, that we play nice... We might need to have - a data_size field in the ntfs_inode to store the real attribute - length. Also need to be careful with initialized_size extention in + simultaneous file extensions. This is given to us by holding i_sem on + the inode. The only places in the kernel when a file is resized are + prepare/commit write and truncate for both of which i_sem is held. + Just have to be careful in readpage/writepage and all other helpers + not running under i_sem that we play nice... + Also need to be careful with initialized_size extention in ntfs_prepare_write. Basically, just be _very_ careful in this code... - OTOH, perhaps i_sem, which is held accross generic_file_write is - sufficient for synchronisation here. We then just need to make sure - ntfs_readpage/writepage/truncate interoperate properly with us. - UPDATE: The above is all ok as it is due to i_sem held. The only - thing that needs to be checked is ntfs_writepage() which does not - hold i_sem. It cannot change i_size but it needs to cope with a - concurrent i_size change. + UPDATE: The onlythingis that need to be checked are read/writepage + which do not hold i_sem. Note writepage cannot change i_size but it + needs to cope with a concurrent i_size change, just like readpage. + Also both need to cope with concurrent the other sizes, i.e. + initialized/allocated/compressed size changing as well. - Implement mft.c::sync_mft_mirror_umount(). We currently will just leave the volume dirty on umount if the final iput(vol->mft_ino) causes a write of any mirrored mft records due to the mft mirror @@ -24,6 +22,14 @@ the problem. - Enable the code for setting the NT4 compatibility flag when we start making NTFS 1.2 specific modifications. + +2.1.23-WIP + + - Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set(). + - Use i_size_read() in fs/ntfs/logfile.c::ntfs_{check,empty}_logfile(). + - Use i_size_read() once and then use the cached value in + fs/ntfs/lcnalloc.c::ntfs_cluster_alloc(). + - Use i_size_read() in fs/ntfs/file.c::ntfs_file_open(). 2.1.22 - Many bug and race fixes and error handling improvements. diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile --- a/fs/ntfs/Makefile 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/Makefile 2004-11-17 19:45:14 -08:00 @@ -6,7 +6,7 @@ index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ unistr.o upcase.o -EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.22\" +EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.23-WIP\" ifeq ($(CONFIG_NTFS_DEBUG),y) EXTRA_CFLAGS += -DDEBUG diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c --- a/fs/ntfs/attrib.c 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/attrib.c 2004-11-17 19:45:14 -08:00 @@ -1127,6 +1127,10 @@ * byte offset @ofs inside the attribute with the constant byte @val. * * This function is effectively like memset() applied to an ntfs attribute. + * Note thie function actually only operates on the page cache pages belonging + * to the ntfs attribute and it marks them dirty after doing the memset(). + * Thus it relies on the vm dirty page write code paths to cause the modified + * pages to be written to the mft record/disk. * * Return 0 on success and -errno on error. An error code of -ESPIPE means * that @ofs + @cnt were outside the end of the attribute and no write was @@ -1155,7 +1159,7 @@ end = ofs + cnt; end_ofs = end & ~PAGE_CACHE_MASK; /* If the end is outside the inode size return -ESPIPE. */ - if (unlikely(end > VFS_I(ni)->i_size)) { + if (unlikely(end > i_size_read(VFS_I(ni)))) { ntfs_error(vol->sb, "Request exceeds end of attribute."); return -ESPIPE; } diff -Nru a/fs/ntfs/file.c b/fs/ntfs/file.c --- a/fs/ntfs/file.c 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/file.c 2004-11-17 19:45:14 -08:00 @@ -47,7 +47,7 @@ static int ntfs_file_open(struct inode *vi, struct file *filp) { if (sizeof(unsigned long) < 8) { - if (vi->i_size > MAX_LFS_FILESIZE) + if (i_size_read(vi) > MAX_LFS_FILESIZE) return -EFBIG; } return generic_file_open(vi, filp); diff -Nru a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c --- a/fs/ntfs/lcnalloc.c 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/lcnalloc.c 2004-11-17 19:45:14 -08:00 @@ -140,6 +140,7 @@ LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn; LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size; s64 clusters; + loff_t i_size; struct inode *lcnbmp_vi; runlist_element *rl = NULL; struct address_space *mapping; @@ -249,6 +250,7 @@ clusters = count; rlpos = rlsize = 0; mapping = lcnbmp_vi->i_mapping; + i_size = i_size_read(lcnbmp_vi); while (1) { ntfs_debug("Start of outer while loop: done_zones 0x%x, " "search_zone %i, pass %i, zone_start 0x%llx, " @@ -263,7 +265,7 @@ last_read_pos = bmp_pos >> 3; ntfs_debug("last_read_pos 0x%llx.", (unsigned long long)last_read_pos); - if (last_read_pos > lcnbmp_vi->i_size) { + if (last_read_pos > i_size) { ntfs_debug("End of attribute reached. " "Skipping to zone_pass_done."); goto zone_pass_done; @@ -287,8 +289,8 @@ buf_size = last_read_pos & ~PAGE_CACHE_MASK; buf = page_address(page) + buf_size; buf_size = PAGE_CACHE_SIZE - buf_size; - if (unlikely(last_read_pos + buf_size > lcnbmp_vi->i_size)) - buf_size = lcnbmp_vi->i_size - last_read_pos; + if (unlikely(last_read_pos + buf_size > i_size)) + buf_size = i_size - last_read_pos; buf_size <<= 3; lcn = bmp_pos & 7; bmp_pos &= ~7; diff -Nru a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c --- a/fs/ntfs/logfile.c 2004-11-17 19:45:14 -08:00 +++ b/fs/ntfs/logfile.c 2004-11-17 19:45:14 -08:00 @@ -443,7 +443,7 @@ /* An empty $LogFile must have been clean before it got emptied. */ if (NVolLogFileEmpty(vol)) goto is_empty; - size = log_vi->i_size; + size = i_size_read(log_vi); /* Make sure the file doesn't exceed the maximum allowed size. */ if (size > MaxLogFileSize) size = MaxLogFileSize; @@ -689,7 +689,8 @@ if (!NVolLogFileEmpty(vol)) { int err; - err = ntfs_attr_set(NTFS_I(log_vi), 0, log_vi->i_size, 0xff); + err = ntfs_attr_set(NTFS_I(log_vi), 0, i_size_read(log_vi), + 0xff); if (unlikely(err)) { ntfs_error(vol->sb, "Failed to fill $LogFile with " "0xff bytes (error code %i).", err);