linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 19/21] ntfs: drop vmtruncate
@ 2012-08-31 14:02 Marco Stornelli
  2012-09-01 20:04 ` Anton Altaparmakov
  0 siblings, 1 reply; 2+ messages in thread
From: Marco Stornelli @ 2012-08-31 14:02 UTC (permalink / raw)
  To: Linux FS Devel; +Cc: Anton Altaparmakov, linux-ntfs-dev, linux-kernel

Removed vmtruncate.

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
---
 fs/ntfs/file.c  |    8 +++++---
 fs/ntfs/inode.c |   11 +++++++++--
 fs/ntfs/inode.h |    4 ++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 1ecf464..5332e90 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -2022,8 +2022,11 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
 				 * allocated space, which is not a disaster.
 				 */
 				i_size = i_size_read(vi);
-				if (pos + bytes > i_size)
-					vmtruncate(vi, i_size);
+				if ((pos + bytes > i_size) &&
+					inode_newsize_ok(vi, i_size) == 0) {
+					truncate_setsize(vi, i_size);
+					ntfs_truncate_vfs(vi);
+				}
 				break;
 			}
 		}
@@ -2227,7 +2230,6 @@ const struct file_operations ntfs_file_ops = {
 
 const struct inode_operations ntfs_file_inode_ops = {
 #ifdef NTFS_RW
-	.truncate	= ntfs_truncate_vfs,
 	.setattr	= ntfs_setattr,
 #endif /* NTFS_RW */
 };
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index c6dbd3d..fe05a92 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2865,9 +2865,11 @@ conv_err_out:
  *
  * See ntfs_truncate() description above for details.
  */
+#ifdef NTFS_RW
 void ntfs_truncate_vfs(struct inode *vi) {
 	ntfs_truncate(vi);
 }
+#endif
 
 /**
  * ntfs_setattr - called from notify_change() when an attribute is being changed
@@ -2913,8 +2915,13 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
 						NInoCompressed(ni) ?
 						"compressed" : "encrypted");
 				err = -EOPNOTSUPP;
-			} else
-				err = vmtruncate(vi, attr->ia_size);
+			} else {
+				err = inode_newsize_ok(vi, attr->ia_size);
+				if (!err) {
+					truncate_setsize(vi, attr->ia_size);
+					ntfs_truncate_vfs(vi);
+				}
+			}
 			if (err || ia_valid == ATTR_SIZE)
 				goto out;
 		} else {
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index db29695..76b6cfb 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -316,6 +316,10 @@ static inline void ntfs_commit_inode(struct inode *vi)
 	return;
 }
 
+#else
+
+static inline void ntfs_truncate_vfs(struct inode *vi) {}
+
 #endif /* NTFS_RW */
 
 #endif /* _LINUX_NTFS_INODE_H */
-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 19/21] ntfs: drop vmtruncate
  2012-08-31 14:02 [PATCH 19/21] ntfs: drop vmtruncate Marco Stornelli
@ 2012-09-01 20:04 ` Anton Altaparmakov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Altaparmakov @ 2012-09-01 20:04 UTC (permalink / raw)
  To: Marco Stornelli; +Cc: Linux FS Devel, linux-ntfs-dev, linux-kernel

Hi,

Looks good though if you call ntfs_truncate() rather than ntfs_truncate_vfs() you can use it to return an error code in the case that ntfs_truncate() fails.  That could be done as a separate patch of course.

You can add my Reviewed-by: or Signed-off-by: to this patch.

Best regards,

	Anton

On 31 Aug 2012, at 15:02, Marco Stornelli <marco.stornelli@gmail.com> wrote:

> Removed vmtruncate.
> 
> Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
> ---
> fs/ntfs/file.c  |    8 +++++---
> fs/ntfs/inode.c |   11 +++++++++--
> fs/ntfs/inode.h |    4 ++++
> 3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 1ecf464..5332e90 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -2022,8 +2022,11 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
> 				 * allocated space, which is not a disaster.
> 				 */
> 				i_size = i_size_read(vi);
> -				if (pos + bytes > i_size)
> -					vmtruncate(vi, i_size);
> +				if ((pos + bytes > i_size) &&
> +					inode_newsize_ok(vi, i_size) == 0) {
> +					truncate_setsize(vi, i_size);
> +					ntfs_truncate_vfs(vi);
> +				}
> 				break;
> 			}
> 		}
> @@ -2227,7 +2230,6 @@ const struct file_operations ntfs_file_ops = {
> 
> const struct inode_operations ntfs_file_inode_ops = {
> #ifdef NTFS_RW
> -	.truncate	= ntfs_truncate_vfs,
> 	.setattr	= ntfs_setattr,
> #endif /* NTFS_RW */
> };
> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
> index c6dbd3d..fe05a92 100644
> --- a/fs/ntfs/inode.c
> +++ b/fs/ntfs/inode.c
> @@ -2865,9 +2865,11 @@ conv_err_out:
>  *
>  * See ntfs_truncate() description above for details.
>  */
> +#ifdef NTFS_RW
> void ntfs_truncate_vfs(struct inode *vi) {
> 	ntfs_truncate(vi);
> }
> +#endif
> 
> /**
>  * ntfs_setattr - called from notify_change() when an attribute is being changed
> @@ -2913,8 +2915,13 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
> 						NInoCompressed(ni) ?
> 						"compressed" : "encrypted");
> 				err = -EOPNOTSUPP;
> -			} else
> -				err = vmtruncate(vi, attr->ia_size);
> +			} else {
> +				err = inode_newsize_ok(vi, attr->ia_size);
> +				if (!err) {
> +					truncate_setsize(vi, attr->ia_size);
> +					ntfs_truncate_vfs(vi);
> +				}
> +			}
> 			if (err || ia_valid == ATTR_SIZE)
> 				goto out;
> 		} else {
> diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
> index db29695..76b6cfb 100644
> --- a/fs/ntfs/inode.h
> +++ b/fs/ntfs/inode.h
> @@ -316,6 +316,10 @@ static inline void ntfs_commit_inode(struct inode *vi)
> 	return;
> }
> 
> +#else
> +
> +static inline void ntfs_truncate_vfs(struct inode *vi) {}
> +
> #endif /* NTFS_RW */
> 
> #endif /* _LINUX_NTFS_INODE_H */
> -- 
> 1.7.3.4

Best regards,

	Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer, http://www.linux-ntfs.org/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-01 20:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-31 14:02 [PATCH 19/21] ntfs: drop vmtruncate Marco Stornelli
2012-09-01 20:04 ` Anton Altaparmakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).