Commit 1d209b00 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: 2.0.14 - Run list merging code cleanup, minor locking changes, typo fixes.

- Change fs/ntfs/super.c::ntfs_statfs() to not rely on BKL by moving
  the locking out of super.c::get_nr_free_mft_records() and taking and
  dropping the mftbmp_lock rw_semaphore in ntfs_statfs() itself.
- Bring attribute run list merging code (fs/ntfs/attrib.c) in sync with
  current userspace ntfs library code. This means that if a merge
  fails the original run lists are always left unmodified instead of
  being silently corrupted.
- Misc typo fixes.
parent 55eebc46
...@@ -247,6 +247,9 @@ ChangeLog ...@@ -247,6 +247,9 @@ ChangeLog
Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
2.0.14:
- Internal changes improving run list merging code and minor locking
change to not rely on BKL in ntfs_statfs().
2.0.13: 2.0.13:
- Internal changes towards using iget5_locked() in preparation for - Internal changes towards using iget5_locked() in preparation for
fake inodes and small cleanups to ntfs_volume structure. fake inodes and small cleanups to ntfs_volume structure.
......
...@@ -28,6 +28,17 @@ ToDo: ...@@ -28,6 +28,17 @@ ToDo:
- Enable NFS exporting of NTFS. - Enable NFS exporting of NTFS.
- Use fake inodes for address space i/o. - Use fake inodes for address space i/o.
2.0.14 - Run list merging code cleanup, minor locking changes, typo fixes.
- Change fs/ntfs/super.c::ntfs_statfs() to not rely on BKL by moving
the locking out of super.c::get_nr_free_mft_records() and taking and
dropping the mftbmp_lock rw_semaphore in ntfs_statfs() itself.
- Bring attribute run list merging code (fs/ntfs/attrib.c) in sync with
current userspace ntfs library code. This means that if a merge
fails the original run lists are always left unmodified instead of
being silently corrupted.
- Misc typo fixes.
2.0.13 - Use iget5_locked() in preparation for fake inodes and small cleanups. 2.0.13 - Use iget5_locked() in preparation for fake inodes and small cleanups.
- Remove nr_mft_bits and the now superfluous union with nr_mft_records - Remove nr_mft_bits and the now superfluous union with nr_mft_records
......
...@@ -5,7 +5,7 @@ obj-$(CONFIG_NTFS_FS) += ntfs.o ...@@ -5,7 +5,7 @@ obj-$(CONFIG_NTFS_FS) += ntfs.o
ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \ ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.13\" EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.14\"
ifeq ($(CONFIG_NTFS_DEBUG),y) ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG EXTRA_CFLAGS += -DDEBUG
......
This diff is collapsed.
...@@ -48,7 +48,7 @@ int post_read_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -48,7 +48,7 @@ int post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
usa_ofs = le16_to_cpu(b->usa_ofs); usa_ofs = le16_to_cpu(b->usa_ofs);
/* Decrement usa_count to get number of fixups. */ /* Decrement usa_count to get number of fixups. */
usa_count = le16_to_cpu(b->usa_count) - 1; usa_count = le16_to_cpu(b->usa_count) - 1;
/* Size and alignement checks. */ /* Size and alignment checks. */
if ( size & (NTFS_BLOCK_SIZE - 1) || if ( size & (NTFS_BLOCK_SIZE - 1) ||
usa_ofs & 1 || usa_ofs & 1 ||
usa_ofs + (usa_count * 2) > size || usa_ofs + (usa_count * 2) > size ||
...@@ -132,7 +132,7 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size) ...@@ -132,7 +132,7 @@ int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
usa_ofs = le16_to_cpu(b->usa_ofs); usa_ofs = le16_to_cpu(b->usa_ofs);
/* Decrement usa_count to get number of fixups. */ /* Decrement usa_count to get number of fixups. */
usa_count = le16_to_cpu(b->usa_count) - 1; usa_count = le16_to_cpu(b->usa_count) - 1;
/* Size and alignement checks. */ /* Size and alignment checks. */
if ( size & (NTFS_BLOCK_SIZE - 1) || if ( size & (NTFS_BLOCK_SIZE - 1) ||
usa_ofs & 1 || usa_ofs & 1 ||
usa_ofs + (usa_count * 2) > size || usa_ofs + (usa_count * 2) > size ||
......
...@@ -1077,7 +1077,7 @@ static BOOL load_system_files(ntfs_volume *vol) ...@@ -1077,7 +1077,7 @@ static BOOL load_system_files(ntfs_volume *vol)
* releases all inodes and memory belonging to the NTFS specific part of the * releases all inodes and memory belonging to the NTFS specific part of the
* super block. * super block.
*/ */
void ntfs_put_super(struct super_block *vfs_sb) static void ntfs_put_super(struct super_block *vfs_sb)
{ {
ntfs_volume *vol = NTFS_SB(vfs_sb); ntfs_volume *vol = NTFS_SB(vfs_sb);
...@@ -1155,7 +1155,7 @@ void ntfs_put_super(struct super_block *vfs_sb) ...@@ -1155,7 +1155,7 @@ void ntfs_put_super(struct super_block *vfs_sb)
* Errors are ignored and we just return the number of free clusters we have * Errors are ignored and we just return the number of free clusters we have
* found. This means we return an underestimate on error. * found. This means we return an underestimate on error.
*/ */
s64 get_nr_free_clusters(ntfs_volume *vol) static s64 get_nr_free_clusters(ntfs_volume *vol)
{ {
struct address_space *mapping = vol->lcnbmp_ino->i_mapping; struct address_space *mapping = vol->lcnbmp_ino->i_mapping;
filler_t *readpage = (filler_t*)mapping->a_ops->readpage; filler_t *readpage = (filler_t*)mapping->a_ops->readpage;
...@@ -1227,7 +1227,7 @@ s64 get_nr_free_clusters(ntfs_volume *vol) ...@@ -1227,7 +1227,7 @@ s64 get_nr_free_clusters(ntfs_volume *vol)
} }
/** /**
* get_nr_free_mft_records - return the number of free inodes on a volume * __get_nr_free_mft_records - return the number of free inodes on a volume
* @vol: ntfs volume for which to obtain free inode count * @vol: ntfs volume for which to obtain free inode count
* *
* Calculate the number of free mft records (inodes) on the mounted NTFS * Calculate the number of free mft records (inodes) on the mounted NTFS
...@@ -1235,8 +1235,10 @@ s64 get_nr_free_clusters(ntfs_volume *vol) ...@@ -1235,8 +1235,10 @@ s64 get_nr_free_clusters(ntfs_volume *vol)
* *
* Errors are ignored and we just return the number of free inodes we have * Errors are ignored and we just return the number of free inodes we have
* found. This means we return an underestimate on error. * found. This means we return an underestimate on error.
*
* NOTE: Caller must hold mftbmp_lock rw_semaphore for reading or writing.
*/ */
unsigned long get_nr_free_mft_records(ntfs_volume *vol) static unsigned long __get_nr_free_mft_records(ntfs_volume *vol)
{ {
struct address_space *mapping; struct address_space *mapping;
filler_t *readpage; filler_t *readpage;
...@@ -1247,7 +1249,6 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol) ...@@ -1247,7 +1249,6 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol)
ntfs_debug("Entering."); ntfs_debug("Entering.");
/* Serialize accesses to the inode bitmap. */ /* Serialize accesses to the inode bitmap. */
down_read(&vol->mftbmp_lock);
mapping = &vol->mftbmp_mapping; mapping = &vol->mftbmp_mapping;
readpage = (filler_t*)mapping->a_ops->readpage; readpage = (filler_t*)mapping->a_ops->readpage;
/* /*
...@@ -1307,7 +1308,6 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol) ...@@ -1307,7 +1308,6 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol)
} }
ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx", ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx",
index - 1); index - 1);
up_read(&vol->mftbmp_lock);
ntfs_debug("Exiting."); ntfs_debug("Exiting.");
return nr_free; return nr_free;
} }
...@@ -1330,7 +1330,7 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol) ...@@ -1330,7 +1330,7 @@ unsigned long get_nr_free_mft_records(ntfs_volume *vol)
* *
* Return 0 on success or -errno on error. * Return 0 on success or -errno on error.
*/ */
int ntfs_statfs(struct super_block *sb, struct statfs *sfs) static int ntfs_statfs(struct super_block *sb, struct statfs *sfs)
{ {
ntfs_volume *vol = NTFS_SB(sb); ntfs_volume *vol = NTFS_SB(sb);
s64 size; s64 size;
...@@ -1354,10 +1354,12 @@ int ntfs_statfs(struct super_block *sb, struct statfs *sfs) ...@@ -1354,10 +1354,12 @@ int ntfs_statfs(struct super_block *sb, struct statfs *sfs)
size = 0LL; size = 0LL;
/* Free blocks avail to non-superuser, same as above on NTFS. */ /* Free blocks avail to non-superuser, same as above on NTFS. */
sfs->f_bavail = sfs->f_bfree = size; sfs->f_bavail = sfs->f_bfree = size;
down_read(&vol->mftbmp_lock);
/* Total file nodes in file system (at this moment in time). */ /* Total file nodes in file system (at this moment in time). */
sfs->f_files = vol->mft_ino->i_size >> vol->mft_record_size_bits; sfs->f_files = vol->mft_ino->i_size >> vol->mft_record_size_bits;
/* Free file nodes in fs (based on current total count). */ /* Free file nodes in fs (based on current total count). */
sfs->f_ffree = get_nr_free_mft_records(vol); sfs->f_ffree = __get_nr_free_mft_records(vol);
up_read(&vol->mftbmp_lock);
/* /*
* File system id. This is extremely *nix flavour dependent and even * File system id. This is extremely *nix flavour dependent and even
* within Linux itself all fs do their own thing. I interpret this to * within Linux itself all fs do their own thing. I interpret this to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment