Commit 16b39f5f authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: 2.0.24 - Cleanups.

- Treat BUG_ON() as ASSERT() not VERIFY(), i.e. do not use side effects
  inside BUG_ON(). (Adam J. Richter)
- Split logical OR expressions inside BUG_ON() into individual BUG_ON()
  calls for improved debugging. (Adam J. Richter)
- Add errors flag to the ntfs volume state, accessed via
  NVol{,Set,Clear}Errors(vol).
- Do not allow read-write remounts of read-only volumes with errors.
- Clarify comment for ntfs file operation sendfile which was added by
  Christoph Hellwig a while ago (just using generic_file_sendfile())
  to say that ntfs ->sendfile is only used for the case where the
  source data is on the ntfs partition and the destination is
  somewhere else, i.e. nothing we need to concern ourselves with.
parent ab50636c
...@@ -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.24:
- Small internal cleanups.
- Support for sendfile system call. (Christoph Hellwig)
2.0.23: 2.0.23:
- Massive internal locking changes to mft record locking. Fixes - Massive internal locking changes to mft record locking. Fixes
various race conditions and deadlocks. various race conditions and deadlocks.
......
...@@ -2,6 +2,22 @@ ToDo: ...@@ -2,6 +2,22 @@ ToDo:
- Find and fix bugs. - Find and fix bugs.
- Enable NFS exporting of NTFS. - Enable NFS exporting of NTFS.
2.0.24 - Cleanups.
- Treat BUG_ON() as ASSERT() not VERIFY(), i.e. do not use side effects
inside BUG_ON(). (Adam J. Richter)
- Split logical OR expressions inside BUG_ON() into individual BUG_ON()
calls for improved debugging. (Adam J. Richter)
- Add errors flag to the ntfs volume state, accessed via
NVol{,Set,Clear}Errors(vol).
- Do not allow read-write remounts of read-only volumes with errors.
- Clarify comment for ntfs file operation sendfile which was added by
Christoph Hellwig a while ago (just using generic_file_sendfile())
to say that ntfs ->sendfile is only used for the case where the
source data is on the ntfs partition and the destination is
somewhere else, i.e. nothing we need to concern ourselves with.
- Add generic_file_write() as our ntfs file write operation.
2.0.23 - Major bug fixes (races, deadlocks, non-i386 architectures). 2.0.23 - Major bug fixes (races, deadlocks, non-i386 architectures).
- Massive internal locking changes to mft record locking. Fixes lock - Massive internal locking changes to mft record locking. Fixes lock
......
...@@ -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.23\" EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.24\"
ifeq ($(CONFIG_NTFS_DEBUG),y) ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG EXTRA_CFLAGS += -DDEBUG
......
...@@ -110,7 +110,8 @@ static inline run_list_element *ntfs_rl_realloc(run_list_element *rl, ...@@ -110,7 +110,8 @@ static inline run_list_element *ntfs_rl_realloc(run_list_element *rl,
static inline BOOL ntfs_are_rl_mergeable(run_list_element *dst, static inline BOOL ntfs_are_rl_mergeable(run_list_element *dst,
run_list_element *src) run_list_element *src)
{ {
BUG_ON(!dst || !src); BUG_ON(!dst);
BUG_ON(!src);
if ((dst->lcn < 0) || (src->lcn < 0)) /* Are we merging holes? */ if ((dst->lcn < 0) || (src->lcn < 0)) /* Are we merging holes? */
return FALSE; return FALSE;
...@@ -192,7 +193,8 @@ static inline run_list_element *ntfs_rl_append(run_list_element *dst, ...@@ -192,7 +193,8 @@ static inline run_list_element *ntfs_rl_append(run_list_element *dst,
BOOL right; BOOL right;
int magic; int magic;
BUG_ON(!dst || !src); BUG_ON(!dst);
BUG_ON(!src);
/* First, check if the right hand end needs merging. */ /* First, check if the right hand end needs merging. */
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
...@@ -258,7 +260,8 @@ static inline run_list_element *ntfs_rl_insert(run_list_element *dst, ...@@ -258,7 +260,8 @@ static inline run_list_element *ntfs_rl_insert(run_list_element *dst,
BOOL hole = FALSE; /* Following a hole */ BOOL hole = FALSE; /* Following a hole */
int magic; int magic;
BUG_ON(!dst || !src); BUG_ON(!dst);
BUG_ON(!src);
/* disc => Discontinuity between the end of @dst and the start of @src. /* disc => Discontinuity between the end of @dst and the start of @src.
* This means we might need to insert a hole. * This means we might need to insert a hole.
...@@ -362,7 +365,8 @@ static inline run_list_element *ntfs_rl_replace(run_list_element *dst, ...@@ -362,7 +365,8 @@ static inline run_list_element *ntfs_rl_replace(run_list_element *dst,
BOOL right; BOOL right;
int magic; int magic;
BUG_ON(!dst || !src); BUG_ON(!dst);
BUG_ON(!src);
/* First, merge the left and right ends, if necessary. */ /* First, merge the left and right ends, if necessary. */
right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
...@@ -423,7 +427,8 @@ static inline run_list_element *ntfs_rl_replace(run_list_element *dst, ...@@ -423,7 +427,8 @@ static inline run_list_element *ntfs_rl_replace(run_list_element *dst,
static inline run_list_element *ntfs_rl_split(run_list_element *dst, int dsize, static inline run_list_element *ntfs_rl_split(run_list_element *dst, int dsize,
run_list_element *src, int ssize, int loc) run_list_element *src, int ssize, int loc)
{ {
BUG_ON(!dst || !src); BUG_ON(!dst);
BUG_ON(!src);
/* Space required: @dst size + @src size + one new hole. */ /* Space required: @dst size + @src size + one new hole. */
dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1); dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1);
......
...@@ -467,7 +467,8 @@ int ntfs_read_compressed_block(struct page *page) ...@@ -467,7 +467,8 @@ int ntfs_read_compressed_block(struct page *page)
* Bad things happen if we get here for anything that is not an * Bad things happen if we get here for anything that is not an
* unnamed $DATA attribute. * unnamed $DATA attribute.
*/ */
BUG_ON(ni->type != AT_DATA || ni->name_len); BUG_ON(ni->type != AT_DATA);
BUG_ON(ni->name_len);
pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS); pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS);
......
...@@ -51,8 +51,15 @@ static int ntfs_file_open(struct inode *vi, struct file *filp) ...@@ -51,8 +51,15 @@ static int ntfs_file_open(struct inode *vi, struct file *filp)
struct file_operations ntfs_file_ops = { struct file_operations ntfs_file_ops = {
.llseek = generic_file_llseek, /* Seek inside file. */ .llseek = generic_file_llseek, /* Seek inside file. */
.read = generic_file_read, /* Read from file. */ .read = generic_file_read, /* Read from file. */
#ifdef NTFS_RW
.write = generic_file_write, /* Write to a file. */
#endif
.mmap = generic_file_mmap, /* Mmap file. */ .mmap = generic_file_mmap, /* Mmap file. */
.sendfile = generic_file_sendfile,/* Zero-copy data send. */ .sendfile = generic_file_sendfile,/* Zero-copy data send with the
data source being on the
ntfs partition. We don't
need to care about the data
destination. */
.open = ntfs_file_open, /* Open file. */ .open = ntfs_file_open, /* Open file. */
}; };
......
...@@ -278,7 +278,9 @@ void ntfs_destroy_big_inode(struct inode *inode) ...@@ -278,7 +278,9 @@ void ntfs_destroy_big_inode(struct inode *inode)
ntfs_inode *ni = NTFS_I(inode); ntfs_inode *ni = NTFS_I(inode);
ntfs_debug("Entering."); ntfs_debug("Entering.");
BUG_ON(ni->page || !atomic_dec_and_test(&ni->count)); BUG_ON(ni->page);
if (!atomic_dec_and_test(&ni->count))
BUG();
kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode)); kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode));
} }
...@@ -299,7 +301,9 @@ static inline ntfs_inode *ntfs_alloc_extent_inode(void) ...@@ -299,7 +301,9 @@ static inline ntfs_inode *ntfs_alloc_extent_inode(void)
void ntfs_destroy_extent_inode(ntfs_inode *ni) void ntfs_destroy_extent_inode(ntfs_inode *ni)
{ {
ntfs_debug("Entering."); ntfs_debug("Entering.");
BUG_ON(ni->page || !atomic_dec_and_test(&ni->count)); BUG_ON(ni->page);
if (!atomic_dec_and_test(&ni->count))
BUG();
kmem_cache_free(ntfs_inode_cache, ni); kmem_cache_free(ntfs_inode_cache, ni);
} }
......
...@@ -307,6 +307,23 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) ...@@ -307,6 +307,23 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
ntfs_debug("Entering with remount options string: %s", opt); ntfs_debug("Entering with remount options string: %s", opt);
#ifndef NTFS_RW
/* For read-only compiled driver, enforce all read-only flags. */
*flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME;
#else
/*
* For the read-write compiled driver, if we are remounting read-write,
* make sure there aren't any volume errors.
*/
if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
if (NVolErrors(vol)) {
ntfs_error(sb, "Volume has errors and is read-only."
"Cannot remount read-write.");
return -EROFS;
}
}
#endif
// FIXME/TODO: If left like this we will have problems with rw->ro and // FIXME/TODO: If left like this we will have problems with rw->ro and
// ro->rw, as well as with sync->async and vice versa remounts. // ro->rw, as well as with sync->async and vice versa remounts.
// Note: The VFS already checks that there are no pending deletes and // Note: The VFS already checks that there are no pending deletes and
...@@ -324,10 +341,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) ...@@ -324,10 +341,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
if (!parse_options(vol, opt)) if (!parse_options(vol, opt))
return -EINVAL; return -EINVAL;
#ifndef NTFS_RW
*flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME;
#endif
return 0; return 0;
} }
......
...@@ -101,6 +101,7 @@ typedef struct { ...@@ -101,6 +101,7 @@ typedef struct {
* Defined bits for the flags field in the ntfs_volume structure. * Defined bits for the flags field in the ntfs_volume structure.
*/ */
typedef enum { typedef enum {
NV_Errors, /* 1: Volume has errors, prevent remount rw. */
NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */ NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
NV_CaseSensitive, /* 1: Treat file names as case sensitive and NV_CaseSensitive, /* 1: Treat file names as case sensitive and
create filenames in the POSIX namespace. create filenames in the POSIX namespace.
...@@ -127,6 +128,7 @@ static inline void NVolClear##flag(ntfs_volume *vol) \ ...@@ -127,6 +128,7 @@ static inline void NVolClear##flag(ntfs_volume *vol) \
} }
/* Emit the ntfs volume bitops functions. */ /* Emit the ntfs volume bitops functions. */
NVOL_FNS(Errors)
NVOL_FNS(ShowSystemFiles) NVOL_FNS(ShowSystemFiles)
NVOL_FNS(CaseSensitive) NVOL_FNS(CaseSensitive)
......
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