aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ntfs')
-rw-r--r--fs/ntfs/ChangeLog2
-rw-r--r--fs/ntfs/attrib.c4
-rw-r--r--fs/ntfs/dir.c8
-rw-r--r--fs/ntfs/file.c20
-rw-r--r--fs/ntfs/index.c6
-rw-r--r--fs/ntfs/inode.c28
-rw-r--r--fs/ntfs/namei.c6
-rw-r--r--fs/ntfs/quota.c6
-rw-r--r--fs/ntfs/super.c44
9 files changed, 71 insertions, 53 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 50a7749cfca1..02f44094bda9 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -884,7 +884,7 @@ ToDo/Notes:
884 884
885 - Add handling for initialized_size != data_size in compressed files. 885 - Add handling for initialized_size != data_size in compressed files.
886 - Reduce function local stack usage from 0x3d4 bytes to just noise in 886 - Reduce function local stack usage from 0x3d4 bytes to just noise in
887 fs/ntfs/upcase.c. (Randy Dunlap <rddunlap@osdl.ord>) 887 fs/ntfs/upcase.c. (Randy Dunlap <rdunlap@xenotime.net>)
888 - Remove compiler warnings for newer gcc. 888 - Remove compiler warnings for newer gcc.
889 - Pages are no longer kmapped by mm/filemap.c::generic_file_write() 889 - Pages are no longer kmapped by mm/filemap.c::generic_file_write()
890 around calls to ->{prepare,commit}_write. Adapt NTFS appropriately 890 around calls to ->{prepare,commit}_write. Adapt NTFS appropriately
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index eda056bac256..9480a0526cd3 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1532,7 +1532,7 @@ int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
1532 * NOTE to self: No changes in the attribute list are required to move from 1532 * NOTE to self: No changes in the attribute list are required to move from
1533 * a resident to a non-resident attribute. 1533 * a resident to a non-resident attribute.
1534 * 1534 *
1535 * Locking: - The caller must hold i_sem on the inode. 1535 * Locking: - The caller must hold i_mutex on the inode.
1536 */ 1536 */
1537int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) 1537int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1538{ 1538{
@@ -1728,7 +1728,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1728 /* 1728 /*
1729 * This needs to be last since the address space operations ->readpage 1729 * This needs to be last since the address space operations ->readpage
1730 * and ->writepage can run concurrently with us as they are not 1730 * and ->writepage can run concurrently with us as they are not
1731 * serialized on i_sem. Note, we are not allowed to fail once we flip 1731 * serialized on i_mutex. Note, we are not allowed to fail once we flip
1732 * this switch, which is another reason to do this last. 1732 * this switch, which is another reason to do this last.
1733 */ 1733 */
1734 NInoSetNonResident(ni); 1734 NInoSetNonResident(ni);
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 795c3d1930f5..b0690d4c8906 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -69,7 +69,7 @@ ntfschar I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'),
69 * work but we don't care for how quickly one can access them. This also fixes 69 * work but we don't care for how quickly one can access them. This also fixes
70 * the dcache aliasing issues. 70 * the dcache aliasing issues.
71 * 71 *
72 * Locking: - Caller must hold i_sem on the directory. 72 * Locking: - Caller must hold i_mutex on the directory.
73 * - Each page cache page in the index allocation mapping must be 73 * - Each page cache page in the index allocation mapping must be
74 * locked whilst being accessed otherwise we may find a corrupt 74 * locked whilst being accessed otherwise we may find a corrupt
75 * page due to it being under ->writepage at the moment which 75 * page due to it being under ->writepage at the moment which
@@ -1085,11 +1085,11 @@ static inline int ntfs_filldir(ntfs_volume *vol, loff_t fpos,
1085 * While this will return the names in random order this doesn't matter for 1085 * While this will return the names in random order this doesn't matter for
1086 * ->readdir but OTOH results in a faster ->readdir. 1086 * ->readdir but OTOH results in a faster ->readdir.
1087 * 1087 *
1088 * VFS calls ->readdir without BKL but with i_sem held. This protects the VFS 1088 * VFS calls ->readdir without BKL but with i_mutex held. This protects the VFS
1089 * parts (e.g. ->f_pos and ->i_size, and it also protects against directory 1089 * parts (e.g. ->f_pos and ->i_size, and it also protects against directory
1090 * modifications). 1090 * modifications).
1091 * 1091 *
1092 * Locking: - Caller must hold i_sem on the directory. 1092 * Locking: - Caller must hold i_mutex on the directory.
1093 * - Each page cache page in the index allocation mapping must be 1093 * - Each page cache page in the index allocation mapping must be
1094 * locked whilst being accessed otherwise we may find a corrupt 1094 * locked whilst being accessed otherwise we may find a corrupt
1095 * page due to it being under ->writepage at the moment which 1095 * page due to it being under ->writepage at the moment which
@@ -1520,7 +1520,7 @@ static int ntfs_dir_open(struct inode *vi, struct file *filp)
1520 * Note: In the past @filp could be NULL so we ignore it as we don't need it 1520 * Note: In the past @filp could be NULL so we ignore it as we don't need it
1521 * anyway. 1521 * anyway.
1522 * 1522 *
1523 * Locking: Caller must hold i_sem on the inode. 1523 * Locking: Caller must hold i_mutex on the inode.
1524 * 1524 *
1525 * TODO: We should probably also write all attribute/index inodes associated 1525 * TODO: We should probably also write all attribute/index inodes associated
1526 * with this inode but since we have no simple way of getting to them we ignore 1526 * with this inode but since we have no simple way of getting to them we ignore
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index c73c8864cbad..3a119a87686a 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -106,7 +106,7 @@ static int ntfs_file_open(struct inode *vi, struct file *filp)
106 * this is the case, the necessary zeroing will also have happened and that all 106 * this is the case, the necessary zeroing will also have happened and that all
107 * metadata is self-consistent. 107 * metadata is self-consistent.
108 * 108 *
109 * Locking: i_sem on the vfs inode corrseponsind to the ntfs inode @ni must be 109 * Locking: i_mutex on the vfs inode corrseponsind to the ntfs inode @ni must be
110 * held by the caller. 110 * held by the caller.
111 */ 111 */
112static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size, 112static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size,
@@ -473,7 +473,7 @@ static inline int ntfs_submit_bh_for_read(struct buffer_head *bh)
473 * @bytes: number of bytes to be written 473 * @bytes: number of bytes to be written
474 * 474 *
475 * This is called for non-resident attributes from ntfs_file_buffered_write() 475 * This is called for non-resident attributes from ntfs_file_buffered_write()
476 * with i_sem held on the inode (@pages[0]->mapping->host). There are 476 * with i_mutex held on the inode (@pages[0]->mapping->host). There are
477 * @nr_pages pages in @pages which are locked but not kmap()ped. The source 477 * @nr_pages pages in @pages which are locked but not kmap()ped. The source
478 * data has not yet been copied into the @pages. 478 * data has not yet been copied into the @pages.
479 * 479 *
@@ -1637,7 +1637,7 @@ err_out:
1637 * @pos: byte position in file at which the write begins 1637 * @pos: byte position in file at which the write begins
1638 * @bytes: number of bytes to be written 1638 * @bytes: number of bytes to be written
1639 * 1639 *
1640 * This is called from ntfs_file_buffered_write() with i_sem held on the inode 1640 * This is called from ntfs_file_buffered_write() with i_mutex held on the inode
1641 * (@pages[0]->mapping->host). There are @nr_pages pages in @pages which are 1641 * (@pages[0]->mapping->host). There are @nr_pages pages in @pages which are
1642 * locked but not kmap()ped. The source data has already been copied into the 1642 * locked but not kmap()ped. The source data has already been copied into the
1643 * @page. ntfs_prepare_pages_for_non_resident_write() has been called before 1643 * @page. ntfs_prepare_pages_for_non_resident_write() has been called before
@@ -1814,7 +1814,7 @@ err_out:
1814/** 1814/**
1815 * ntfs_file_buffered_write - 1815 * ntfs_file_buffered_write -
1816 * 1816 *
1817 * Locking: The vfs is holding ->i_sem on the inode. 1817 * Locking: The vfs is holding ->i_mutex on the inode.
1818 */ 1818 */
1819static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, 1819static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
1820 const struct iovec *iov, unsigned long nr_segs, 1820 const struct iovec *iov, unsigned long nr_segs,
@@ -2173,7 +2173,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
2173 err = remove_suid(file->f_dentry); 2173 err = remove_suid(file->f_dentry);
2174 if (err) 2174 if (err)
2175 goto out; 2175 goto out;
2176 inode_update_time(inode, 1); 2176 file_update_time(file);
2177 written = ntfs_file_buffered_write(iocb, iov, nr_segs, pos, ppos, 2177 written = ntfs_file_buffered_write(iocb, iov, nr_segs, pos, ppos,
2178 count); 2178 count);
2179out: 2179out:
@@ -2196,9 +2196,9 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const char __user *buf,
2196 2196
2197 BUG_ON(iocb->ki_pos != pos); 2197 BUG_ON(iocb->ki_pos != pos);
2198 2198
2199 down(&inode->i_sem); 2199 mutex_lock(&inode->i_mutex);
2200 ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); 2200 ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
2201 up(&inode->i_sem); 2201 mutex_unlock(&inode->i_mutex);
2202 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2202 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2203 int err = sync_page_range(inode, mapping, pos, ret); 2203 int err = sync_page_range(inode, mapping, pos, ret);
2204 if (err < 0) 2204 if (err < 0)
@@ -2221,12 +2221,12 @@ static ssize_t ntfs_file_writev(struct file *file, const struct iovec *iov,
2221 struct kiocb kiocb; 2221 struct kiocb kiocb;
2222 ssize_t ret; 2222 ssize_t ret;
2223 2223
2224 down(&inode->i_sem); 2224 mutex_lock(&inode->i_mutex);
2225 init_sync_kiocb(&kiocb, file); 2225 init_sync_kiocb(&kiocb, file);
2226 ret = ntfs_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos); 2226 ret = ntfs_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos);
2227 if (ret == -EIOCBQUEUED) 2227 if (ret == -EIOCBQUEUED)
2228 ret = wait_on_sync_kiocb(&kiocb); 2228 ret = wait_on_sync_kiocb(&kiocb);
2229 up(&inode->i_sem); 2229 mutex_unlock(&inode->i_mutex);
2230 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2230 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2231 int err = sync_page_range(inode, mapping, *ppos - ret, ret); 2231 int err = sync_page_range(inode, mapping, *ppos - ret, ret);
2232 if (err < 0) 2232 if (err < 0)
@@ -2269,7 +2269,7 @@ static ssize_t ntfs_file_write(struct file *file, const char __user *buf,
2269 * Note: In the past @filp could be NULL so we ignore it as we don't need it 2269 * Note: In the past @filp could be NULL so we ignore it as we don't need it
2270 * anyway. 2270 * anyway.
2271 * 2271 *
2272 * Locking: Caller must hold i_sem on the inode. 2272 * Locking: Caller must hold i_mutex on the inode.
2273 * 2273 *
2274 * TODO: We should probably also write all attribute/index inodes associated 2274 * TODO: We should probably also write all attribute/index inodes associated
2275 * with this inode but since we have no simple way of getting to them we ignore 2275 * with this inode but since we have no simple way of getting to them we ignore
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index 8f2d5727546f..9f5427c2d105 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -32,7 +32,7 @@
32 * Allocate a new index context, initialize it with @idx_ni and return it. 32 * Allocate a new index context, initialize it with @idx_ni and return it.
33 * Return NULL if allocation failed. 33 * Return NULL if allocation failed.
34 * 34 *
35 * Locking: Caller must hold i_sem on the index inode. 35 * Locking: Caller must hold i_mutex on the index inode.
36 */ 36 */
37ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni) 37ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
38{ 38{
@@ -50,7 +50,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
50 * 50 *
51 * Release the index context @ictx, releasing all associated resources. 51 * Release the index context @ictx, releasing all associated resources.
52 * 52 *
53 * Locking: Caller must hold i_sem on the index inode. 53 * Locking: Caller must hold i_mutex on the index inode.
54 */ 54 */
55void ntfs_index_ctx_put(ntfs_index_context *ictx) 55void ntfs_index_ctx_put(ntfs_index_context *ictx)
56{ 56{
@@ -106,7 +106,7 @@ void ntfs_index_ctx_put(ntfs_index_context *ictx)
106 * or ntfs_index_entry_write() before the call to ntfs_index_ctx_put() to 106 * or ntfs_index_entry_write() before the call to ntfs_index_ctx_put() to
107 * ensure that the changes are written to disk. 107 * ensure that the changes are written to disk.
108 * 108 *
109 * Locking: - Caller must hold i_sem on the index inode. 109 * Locking: - Caller must hold i_mutex on the index inode.
110 * - Each page cache page in the index allocation mapping must be 110 * - Each page cache page in the index allocation mapping must be
111 * locked whilst being accessed otherwise we may find a corrupt 111 * locked whilst being accessed otherwise we may find a corrupt
112 * page due to it being under ->writepage at the moment which 112 * page due to it being under ->writepage at the moment which
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b24f4c4b2c5c..ea1bd3feea1b 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2125,13 +2125,13 @@ void ntfs_put_inode(struct inode *vi)
2125 ntfs_inode *ni = NTFS_I(vi); 2125 ntfs_inode *ni = NTFS_I(vi);
2126 if (NInoIndexAllocPresent(ni)) { 2126 if (NInoIndexAllocPresent(ni)) {
2127 struct inode *bvi = NULL; 2127 struct inode *bvi = NULL;
2128 down(&vi->i_sem); 2128 mutex_lock(&vi->i_mutex);
2129 if (atomic_read(&vi->i_count) == 2) { 2129 if (atomic_read(&vi->i_count) == 2) {
2130 bvi = ni->itype.index.bmp_ino; 2130 bvi = ni->itype.index.bmp_ino;
2131 if (bvi) 2131 if (bvi)
2132 ni->itype.index.bmp_ino = NULL; 2132 ni->itype.index.bmp_ino = NULL;
2133 } 2133 }
2134 up(&vi->i_sem); 2134 mutex_unlock(&vi->i_mutex);
2135 if (bvi) 2135 if (bvi)
2136 iput(bvi); 2136 iput(bvi);
2137 } 2137 }
@@ -2311,7 +2311,7 @@ static const char *es = " Leaving inconsistent metadata. Unmount and run "
2311 * 2311 *
2312 * Returns 0 on success or -errno on error. 2312 * Returns 0 on success or -errno on error.
2313 * 2313 *
2314 * Called with ->i_sem held. In all but one case ->i_alloc_sem is held for 2314 * Called with ->i_mutex held. In all but one case ->i_alloc_sem is held for
2315 * writing. The only case in the kernel where ->i_alloc_sem is not held is 2315 * writing. The only case in the kernel where ->i_alloc_sem is not held is
2316 * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called 2316 * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called
2317 * with the current i_size as the offset. The analogous place in NTFS is in 2317 * with the current i_size as the offset. The analogous place in NTFS is in
@@ -2767,7 +2767,25 @@ unm_done:
2767 up_write(&ni->runlist.lock); 2767 up_write(&ni->runlist.lock);
2768done: 2768done:
2769 /* Update the mtime and ctime on the base inode. */ 2769 /* Update the mtime and ctime on the base inode. */
2770 inode_update_time(VFS_I(base_ni), 1); 2770 /* normally ->truncate shouldn't update ctime or mtime,
2771 * but ntfs did before so it got a copy & paste version
2772 * of file_update_time. one day someone should fix this
2773 * for real.
2774 */
2775 if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) {
2776 struct timespec now = current_fs_time(VFS_I(base_ni)->i_sb);
2777 int sync_it = 0;
2778
2779 if (!timespec_equal(&VFS_I(base_ni)->i_mtime, &now) ||
2780 !timespec_equal(&VFS_I(base_ni)->i_ctime, &now))
2781 sync_it = 1;
2782 VFS_I(base_ni)->i_mtime = now;
2783 VFS_I(base_ni)->i_ctime = now;
2784
2785 if (sync_it)
2786 mark_inode_dirty_sync(VFS_I(base_ni));
2787 }
2788
2771 if (likely(!err)) { 2789 if (likely(!err)) {
2772 NInoClearTruncateFailed(ni); 2790 NInoClearTruncateFailed(ni);
2773 ntfs_debug("Done."); 2791 ntfs_debug("Done.");
@@ -2831,7 +2849,7 @@ void ntfs_truncate_vfs(struct inode *vi) {
2831 * We also abort all changes of user, group, and mode as we do not implement 2849 * We also abort all changes of user, group, and mode as we do not implement
2832 * the NTFS ACLs yet. 2850 * the NTFS ACLs yet.
2833 * 2851 *
2834 * Called with ->i_sem held. For the ATTR_SIZE (i.e. ->truncate) case, also 2852 * Called with ->i_mutex held. For the ATTR_SIZE (i.e. ->truncate) case, also
2835 * called with ->i_alloc_sem held for writing. 2853 * called with ->i_alloc_sem held for writing.
2836 * 2854 *
2837 * Basically this is a copy of generic notify_change() and inode_setattr() 2855 * Basically this is a copy of generic notify_change() and inode_setattr()
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 351dbc3b6e40..5ea9eb93af62 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -96,7 +96,7 @@
96 * name. We then convert the name to the current NLS code page, and proceed 96 * name. We then convert the name to the current NLS code page, and proceed
97 * searching for a dentry with this name, etc, as in case 2), above. 97 * searching for a dentry with this name, etc, as in case 2), above.
98 * 98 *
99 * Locking: Caller must hold i_sem on the directory. 99 * Locking: Caller must hold i_mutex on the directory.
100 */ 100 */
101static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, 101static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
102 struct nameidata *nd) 102 struct nameidata *nd)
@@ -254,7 +254,7 @@ handle_name:
254 nls_name.hash = full_name_hash(nls_name.name, nls_name.len); 254 nls_name.hash = full_name_hash(nls_name.name, nls_name.len);
255 255
256 /* 256 /*
257 * Note: No need for dent->d_lock lock as i_sem is held on the 257 * Note: No need for dent->d_lock lock as i_mutex is held on the
258 * parent inode. 258 * parent inode.
259 */ 259 */
260 260
@@ -374,7 +374,7 @@ struct inode_operations ntfs_dir_inode_ops = {
374 * The code is based on the ext3 ->get_parent() implementation found in 374 * The code is based on the ext3 ->get_parent() implementation found in
375 * fs/ext3/namei.c::ext3_get_parent(). 375 * fs/ext3/namei.c::ext3_get_parent().
376 * 376 *
377 * Note: ntfs_get_parent() is called with @child_dent->d_inode->i_sem down. 377 * Note: ntfs_get_parent() is called with @child_dent->d_inode->i_mutex down.
378 * 378 *
379 * Return the dentry of the parent directory on success or the error code on 379 * Return the dentry of the parent directory on success or the error code on
380 * error (IS_ERR() is true). 380 * error (IS_ERR() is true).
diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c
index 833df2a4e9fb..d0ef4182147b 100644
--- a/fs/ntfs/quota.c
+++ b/fs/ntfs/quota.c
@@ -48,7 +48,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
48 ntfs_error(vol->sb, "Quota inodes are not open."); 48 ntfs_error(vol->sb, "Quota inodes are not open.");
49 return FALSE; 49 return FALSE;
50 } 50 }
51 down(&vol->quota_q_ino->i_sem); 51 mutex_lock(&vol->quota_q_ino->i_mutex);
52 ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino)); 52 ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino));
53 if (!ictx) { 53 if (!ictx) {
54 ntfs_error(vol->sb, "Failed to get index context."); 54 ntfs_error(vol->sb, "Failed to get index context.");
@@ -98,7 +98,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
98 ntfs_index_entry_mark_dirty(ictx); 98 ntfs_index_entry_mark_dirty(ictx);
99set_done: 99set_done:
100 ntfs_index_ctx_put(ictx); 100 ntfs_index_ctx_put(ictx);
101 up(&vol->quota_q_ino->i_sem); 101 mutex_unlock(&vol->quota_q_ino->i_mutex);
102 /* 102 /*
103 * We set the flag so we do not try to mark the quotas out of date 103 * We set the flag so we do not try to mark the quotas out of date
104 * again on remount. 104 * again on remount.
@@ -110,7 +110,7 @@ done:
110err_out: 110err_out:
111 if (ictx) 111 if (ictx)
112 ntfs_index_ctx_put(ictx); 112 ntfs_index_ctx_put(ictx);
113 up(&vol->quota_q_ino->i_sem); 113 mutex_unlock(&vol->quota_q_ino->i_mutex);
114 return FALSE; 114 return FALSE;
115} 115}
116 116
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c16db9e1a8a..c3a3f1a8310b 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -443,8 +443,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
443 443
444 ntfs_debug("Entering with remount options string: %s", opt); 444 ntfs_debug("Entering with remount options string: %s", opt);
445#ifndef NTFS_RW 445#ifndef NTFS_RW
446 /* For read-only compiled driver, enforce all read-only flags. */ 446 /* For read-only compiled driver, enforce read-only flag. */
447 *flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 447 *flags |= MS_RDONLY;
448#else /* NTFS_RW */ 448#else /* NTFS_RW */
449 /* 449 /*
450 * For the read-write compiled driver, if we are remounting read-write, 450 * For the read-write compiled driver, if we are remounting read-write,
@@ -1213,10 +1213,10 @@ static int check_windows_hibernation_status(ntfs_volume *vol)
1213 * Find the inode number for the hibernation file by looking up the 1213 * Find the inode number for the hibernation file by looking up the
1214 * filename hiberfil.sys in the root directory. 1214 * filename hiberfil.sys in the root directory.
1215 */ 1215 */
1216 down(&vol->root_ino->i_sem); 1216 mutex_lock(&vol->root_ino->i_mutex);
1217 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12, 1217 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12,
1218 &name); 1218 &name);
1219 up(&vol->root_ino->i_sem); 1219 mutex_unlock(&vol->root_ino->i_mutex);
1220 if (IS_ERR_MREF(mref)) { 1220 if (IS_ERR_MREF(mref)) {
1221 ret = MREF_ERR(mref); 1221 ret = MREF_ERR(mref);
1222 /* If the file does not exist, Windows is not hibernated. */ 1222 /* If the file does not exist, Windows is not hibernated. */
@@ -1307,10 +1307,10 @@ static BOOL load_and_init_quota(ntfs_volume *vol)
1307 * Find the inode number for the quota file by looking up the filename 1307 * Find the inode number for the quota file by looking up the filename
1308 * $Quota in the extended system files directory $Extend. 1308 * $Quota in the extended system files directory $Extend.
1309 */ 1309 */
1310 down(&vol->extend_ino->i_sem); 1310 mutex_lock(&vol->extend_ino->i_mutex);
1311 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6, 1311 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6,
1312 &name); 1312 &name);
1313 up(&vol->extend_ino->i_sem); 1313 mutex_unlock(&vol->extend_ino->i_mutex);
1314 if (IS_ERR_MREF(mref)) { 1314 if (IS_ERR_MREF(mref)) {
1315 /* 1315 /*
1316 * If the file does not exist, quotas are disabled and have 1316 * If the file does not exist, quotas are disabled and have
@@ -1390,10 +1390,10 @@ static BOOL load_and_init_usnjrnl(ntfs_volume *vol)
1390 * Find the inode number for the transaction log file by looking up the 1390 * Find the inode number for the transaction log file by looking up the
1391 * filename $UsnJrnl in the extended system files directory $Extend. 1391 * filename $UsnJrnl in the extended system files directory $Extend.
1392 */ 1392 */
1393 down(&vol->extend_ino->i_sem); 1393 mutex_lock(&vol->extend_ino->i_mutex);
1394 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8, 1394 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8,
1395 &name); 1395 &name);
1396 up(&vol->extend_ino->i_sem); 1396 mutex_unlock(&vol->extend_ino->i_mutex);
1397 if (IS_ERR_MREF(mref)) { 1397 if (IS_ERR_MREF(mref)) {
1398 /* 1398 /*
1399 * If the file does not exist, transaction logging is disabled, 1399 * If the file does not exist, transaction logging is disabled,
@@ -1721,7 +1721,7 @@ static BOOL load_system_files(ntfs_volume *vol)
1721 es3); 1721 es3);
1722 goto iput_mirr_err_out; 1722 goto iput_mirr_err_out;
1723 } 1723 }
1724 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1724 sb->s_flags |= MS_RDONLY;
1725 ntfs_error(sb, "%s. Mounting read-only%s", 1725 ntfs_error(sb, "%s. Mounting read-only%s",
1726 !vol->mftmirr_ino ? es1 : es2, es3); 1726 !vol->mftmirr_ino ? es1 : es2, es3);
1727 } else 1727 } else
@@ -1837,7 +1837,7 @@ get_ctx_vol_failed:
1837 es1, es2); 1837 es1, es2);
1838 goto iput_vol_err_out; 1838 goto iput_vol_err_out;
1839 } 1839 }
1840 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1840 sb->s_flags |= MS_RDONLY;
1841 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1841 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1842 } else 1842 } else
1843 ntfs_warning(sb, "%s. Will not be able to remount " 1843 ntfs_warning(sb, "%s. Will not be able to remount "
@@ -1874,7 +1874,7 @@ get_ctx_vol_failed:
1874 } 1874 }
1875 goto iput_logfile_err_out; 1875 goto iput_logfile_err_out;
1876 } 1876 }
1877 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1877 sb->s_flags |= MS_RDONLY;
1878 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1878 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1879 } else 1879 } else
1880 ntfs_warning(sb, "%s. Will not be able to remount " 1880 ntfs_warning(sb, "%s. Will not be able to remount "
@@ -1919,7 +1919,7 @@ get_ctx_vol_failed:
1919 es1, es2); 1919 es1, es2);
1920 goto iput_root_err_out; 1920 goto iput_root_err_out;
1921 } 1921 }
1922 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1922 sb->s_flags |= MS_RDONLY;
1923 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1923 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1924 } else 1924 } else
1925 ntfs_warning(sb, "%s. Will not be able to remount " 1925 ntfs_warning(sb, "%s. Will not be able to remount "
@@ -1943,7 +1943,7 @@ get_ctx_vol_failed:
1943 goto iput_root_err_out; 1943 goto iput_root_err_out;
1944 } 1944 }
1945 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1945 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1946 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1946 sb->s_flags |= MS_RDONLY;
1947 /* 1947 /*
1948 * Do not set NVolErrors() because ntfs_remount() might manage 1948 * Do not set NVolErrors() because ntfs_remount() might manage
1949 * to set the dirty flag in which case all would be well. 1949 * to set the dirty flag in which case all would be well.
@@ -1970,7 +1970,7 @@ get_ctx_vol_failed:
1970 goto iput_root_err_out; 1970 goto iput_root_err_out;
1971 } 1971 }
1972 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1972 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1973 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1973 sb->s_flags |= MS_RDONLY;
1974 NVolSetErrors(vol); 1974 NVolSetErrors(vol);
1975 } 1975 }
1976#endif 1976#endif
@@ -1989,7 +1989,7 @@ get_ctx_vol_failed:
1989 goto iput_root_err_out; 1989 goto iput_root_err_out;
1990 } 1990 }
1991 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 1991 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
1992 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 1992 sb->s_flags |= MS_RDONLY;
1993 NVolSetErrors(vol); 1993 NVolSetErrors(vol);
1994 } 1994 }
1995#endif /* NTFS_RW */ 1995#endif /* NTFS_RW */
@@ -2030,7 +2030,7 @@ get_ctx_vol_failed:
2030 es1, es2); 2030 es1, es2);
2031 goto iput_quota_err_out; 2031 goto iput_quota_err_out;
2032 } 2032 }
2033 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 2033 sb->s_flags |= MS_RDONLY;
2034 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 2034 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
2035 } else 2035 } else
2036 ntfs_warning(sb, "%s. Will not be able to remount " 2036 ntfs_warning(sb, "%s. Will not be able to remount "
@@ -2053,7 +2053,7 @@ get_ctx_vol_failed:
2053 goto iput_quota_err_out; 2053 goto iput_quota_err_out;
2054 } 2054 }
2055 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 2055 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
2056 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 2056 sb->s_flags |= MS_RDONLY;
2057 NVolSetErrors(vol); 2057 NVolSetErrors(vol);
2058 } 2058 }
2059 /* 2059 /*
@@ -2074,7 +2074,7 @@ get_ctx_vol_failed:
2074 es1, es2); 2074 es1, es2);
2075 goto iput_usnjrnl_err_out; 2075 goto iput_usnjrnl_err_out;
2076 } 2076 }
2077 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 2077 sb->s_flags |= MS_RDONLY;
2078 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 2078 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
2079 } else 2079 } else
2080 ntfs_warning(sb, "%s. Will not be able to remount " 2080 ntfs_warning(sb, "%s. Will not be able to remount "
@@ -2097,7 +2097,7 @@ get_ctx_vol_failed:
2097 goto iput_usnjrnl_err_out; 2097 goto iput_usnjrnl_err_out;
2098 } 2098 }
2099 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); 2099 ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
2100 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 2100 sb->s_flags |= MS_RDONLY;
2101 NVolSetErrors(vol); 2101 NVolSetErrors(vol);
2102 } 2102 }
2103#endif /* NTFS_RW */ 2103#endif /* NTFS_RW */
@@ -2312,9 +2312,9 @@ static void ntfs_put_super(struct super_block *sb)
2312 if (!list_empty(&sb->s_dirty)) { 2312 if (!list_empty(&sb->s_dirty)) {
2313 const char *s1, *s2; 2313 const char *s1, *s2;
2314 2314
2315 down(&vol->mft_ino->i_sem); 2315 mutex_lock(&vol->mft_ino->i_mutex);
2316 truncate_inode_pages(vol->mft_ino->i_mapping, 0); 2316 truncate_inode_pages(vol->mft_ino->i_mapping, 0);
2317 up(&vol->mft_ino->i_sem); 2317 mutex_unlock(&vol->mft_ino->i_mutex);
2318 write_inode_now(vol->mft_ino, 1); 2318 write_inode_now(vol->mft_ino, 1);
2319 if (!list_empty(&sb->s_dirty)) { 2319 if (!list_empty(&sb->s_dirty)) {
2320 static const char *_s1 = "inodes"; 2320 static const char *_s1 = "inodes";
@@ -2689,7 +2689,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
2689 2689
2690 ntfs_debug("Entering."); 2690 ntfs_debug("Entering.");
2691#ifndef NTFS_RW 2691#ifndef NTFS_RW
2692 sb->s_flags |= MS_RDONLY | MS_NOATIME | MS_NODIRATIME; 2692 sb->s_flags |= MS_RDONLY;
2693#endif /* ! NTFS_RW */ 2693#endif /* ! NTFS_RW */
2694 /* Allocate a new ntfs_volume and place it in sb->s_fs_info. */ 2694 /* Allocate a new ntfs_volume and place it in sb->s_fs_info. */
2695 sb->s_fs_info = kmalloc(sizeof(ntfs_volume), GFP_NOFS); 2695 sb->s_fs_info = kmalloc(sizeof(ntfs_volume), GFP_NOFS);