Commit 5a06b739 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: - Change fs/ntfs/inode.c::ntfs_truncate() to return an error code

        instead of void and provide a helper ntfs_truncate_vfs() for the
        vfs ->truncate method.
      - Add a new ntfs inode flag NInoTruncateFailed() and modify
        fs/ntfs/inode.c::ntfs_truncate() to set and clear it appropriately.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent 089aee7d
...@@ -24,6 +24,11 @@ ToDo/Notes: ...@@ -24,6 +24,11 @@ ToDo/Notes:
2.1.22-WIP 2.1.22-WIP
- Improve error handling in fs/ntfs/inode.c::ntfs_truncate(). - Improve error handling in fs/ntfs/inode.c::ntfs_truncate().
- Change fs/ntfs/inode.c::ntfs_truncate() to return an error code
instead of void and provide a helper ntfs_truncate_vfs() for the
vfs ->truncate method.
- Add a new ntfs inode flag NInoTruncateFailed() and modify
fs/ntfs/inode.c::ntfs_truncate() to set and clear it appropriately.
2.1.21 - Fix some races and bugs, rewrite mft write code, add mft allocator. 2.1.21 - Fix some races and bugs, rewrite mft write code, add mft allocator.
......
...@@ -145,7 +145,7 @@ struct file_operations ntfs_file_ops = { ...@@ -145,7 +145,7 @@ struct file_operations ntfs_file_ops = {
struct inode_operations ntfs_file_inode_ops = { struct inode_operations ntfs_file_inode_ops = {
#ifdef NTFS_RW #ifdef NTFS_RW
.truncate = ntfs_truncate, .truncate = ntfs_truncate_vfs,
.setattr = ntfs_setattr, .setattr = ntfs_setattr,
#endif /* NTFS_RW */ #endif /* NTFS_RW */
}; };
......
...@@ -2263,13 +2263,15 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) ...@@ -2263,13 +2263,15 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt)
* This implies for us that @vi is a file inode rather than a directory, index, * This implies for us that @vi is a file inode rather than a directory, index,
* or attribute inode as well as that @vi is a base inode. * or attribute inode as well as that @vi is a base inode.
* *
* Returns 0 on success or -errno on error.
*
* Called with ->i_sem held. In all but one case ->i_alloc_sem is held for * Called with ->i_sem held. In all but one case ->i_alloc_sem is held for
* writing. The only case where ->i_alloc_sem is not held is * writing. The only case where ->i_alloc_sem is not held is
* mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called
* with the current i_size as the offset which means that it is a noop as far * with the current i_size as the offset which means that it is a noop as far
* as ntfs_truncate() is concerned. * as ntfs_truncate() is concerned.
*/ */
void ntfs_truncate(struct inode *vi) int ntfs_truncate(struct inode *vi)
{ {
ntfs_inode *ni = NTFS_I(vi); ntfs_inode *ni = NTFS_I(vi);
ntfs_volume *vol = ni->vol; ntfs_volume *vol = ni->vol;
...@@ -2323,7 +2325,8 @@ void ntfs_truncate(struct inode *vi) ...@@ -2323,7 +2325,8 @@ void ntfs_truncate(struct inode *vi)
ntfs_attr_put_search_ctx(ctx); ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni); unmap_mft_record(ni);
ntfs_debug("Done."); ntfs_debug("Done.");
return; NInoClearTruncateFailed(ni);
return 0;
err_out: err_out:
if (err != -ENOMEM) { if (err != -ENOMEM) {
NVolSetErrors(vol); NVolSetErrors(vol);
...@@ -2333,7 +2336,20 @@ void ntfs_truncate(struct inode *vi) ...@@ -2333,7 +2336,20 @@ void ntfs_truncate(struct inode *vi)
ntfs_attr_put_search_ctx(ctx); ntfs_attr_put_search_ctx(ctx);
if (m) if (m)
unmap_mft_record(ni); unmap_mft_record(ni);
return; NInoSetTruncateFailed(ni);
return err;
}
/**
* ntfs_truncate_vfs - wrapper for ntfs_truncate() that has no return value
* @vi: inode for which the i_size was changed
*
* Wrapper for ntfs_truncate() that has no return value.
*
* See ntfs_truncate() description above for details.
*/
void ntfs_truncate_vfs(struct inode *vi) {
ntfs_truncate(vi);
} }
/** /**
......
...@@ -165,6 +165,7 @@ typedef enum { ...@@ -165,6 +165,7 @@ typedef enum {
NI_Sparse, /* 1: Unnamed data attr is sparse (f). NI_Sparse, /* 1: Unnamed data attr is sparse (f).
1: Create sparse files by default (d). 1: Create sparse files by default (d).
1: Attribute is sparse (a). */ 1: Attribute is sparse (a). */
NI_TruncateFailed, /* 1: Last ntfs_truncate() call failed. */
} ntfs_inode_state_bits; } ntfs_inode_state_bits;
/* /*
...@@ -216,6 +217,7 @@ NINO_FNS(IndexAllocPresent) ...@@ -216,6 +217,7 @@ NINO_FNS(IndexAllocPresent)
NINO_FNS(Compressed) NINO_FNS(Compressed)
NINO_FNS(Encrypted) NINO_FNS(Encrypted)
NINO_FNS(Sparse) NINO_FNS(Sparse)
NINO_FNS(TruncateFailed)
/* /*
* The full structure containing a ntfs_inode and a vfs struct inode. Used for * The full structure containing a ntfs_inode and a vfs struct inode. Used for
...@@ -300,7 +302,8 @@ extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt); ...@@ -300,7 +302,8 @@ extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt);
#ifdef NTFS_RW #ifdef NTFS_RW
extern void ntfs_truncate(struct inode *vi); extern int ntfs_truncate(struct inode *vi);
extern void ntfs_truncate_vfs(struct inode *vi);
extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr); extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr);
......
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