* [PATCH] hfsplus: fix expand when not enough available space
@ 2015-03-23 2:53 Sergei Antonov
2015-03-23 17:28 ` Viacheslav Dubeyko
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Antonov @ 2015-03-23 2:53 UTC (permalink / raw)
To: linux-fsdevel
Cc: Andrew Morton, Vyacheslav Dubeyko, Hin-Tak Leung,
Anton Altaparmakov, Al Viro, Christoph Hellwig, Sougata Santra,
Sergei Antonov
HFS+ does not support file size > allocated size, therefore the following
command should fail:
truncate --size=<size exceeding available space> <some file>
However, it ends successfully. The driver returns success despite having been
unable to allocate the requested space for the file. Also filesystem check finds
an error:
Checking catalog file.
Incorrect size for file test_file
(It should be 469094400 instead of 1000000000)
Add a piece of code analogous to code in the fat driver.
Now a proper error is returned and filesystem remains consistent.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Vyacheslav Dubeyko <slava@dubeyko.com>
Cc: Hin-Tak Leung <htl10@users.sourceforge.net>
Cc: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Sougata Santra <sougata@tuxera.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
fs/hfsplus/inode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 0cf786f..7691cc1 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -254,6 +254,12 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode);
+ if (attr->ia_size > inode->i_size) {
+ error = generic_cont_expand_simple(inode,
+ attr->ia_size);
+ if (error)
+ return error;
+ }
truncate_setsize(inode, attr->ia_size);
hfsplus_file_truncate(inode);
}
--
2.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hfsplus: fix expand when not enough available space
2015-03-23 2:53 [PATCH] hfsplus: fix expand when not enough available space Sergei Antonov
@ 2015-03-23 17:28 ` Viacheslav Dubeyko
0 siblings, 0 replies; 3+ messages in thread
From: Viacheslav Dubeyko @ 2015-03-23 17:28 UTC (permalink / raw)
To: Sergei Antonov
Cc: linux-fsdevel, Andrew Morton, Hin-Tak Leung, Anton Altaparmakov,
Al Viro, Christoph Hellwig, Sougata Santra
On Mon, 2015-03-23 at 03:53 +0100, Sergei Antonov wrote:
> HFS+ does not support file size > allocated size, therefore the following
> command should fail:
> truncate --size=<size exceeding available space> <some file>
> However, it ends successfully. The driver returns success despite having been
> unable to allocate the requested space for the file. Also filesystem check finds
> an error:
> Checking catalog file.
> Incorrect size for file test_file
> (It should be 469094400 instead of 1000000000)
>
> Add a piece of code analogous to code in the fat driver.
> Now a proper error is returned and filesystem remains consistent.
>
To be honest, I am not fully understand what is the case of the fix. As
a result, I can understand correctness of the fix. Could you describe
the issue and the fix in more details? Could you provide more clear
description of the use-case of such issue? Anyway, this fix requires in
more clear and detailed description.
Thanks,
Vyacheslav Dubeyko.
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Vyacheslav Dubeyko <slava@dubeyko.com>
> Cc: Hin-Tak Leung <htl10@users.sourceforge.net>
> Cc: Anton Altaparmakov <aia21@cam.ac.uk>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Sougata Santra <sougata@tuxera.com>
> Signed-off-by: Sergei Antonov <saproj@gmail.com>
> ---
> fs/hfsplus/inode.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 0cf786f..7691cc1 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -254,6 +254,12 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
> if ((attr->ia_valid & ATTR_SIZE) &&
> attr->ia_size != i_size_read(inode)) {
> inode_dio_wait(inode);
> + if (attr->ia_size > inode->i_size) {
> + error = generic_cont_expand_simple(inode,
> + attr->ia_size);
> + if (error)
> + return error;
> + }
> truncate_setsize(inode, attr->ia_size);
> hfsplus_file_truncate(inode);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hfsplus: fix expand when not enough available space
[not found] <1427133643.76486.YahooMailBasic@web172302.mail.ir2.yahoo.com>
@ 2015-03-23 18:16 ` Viacheslav Dubeyko
0 siblings, 0 replies; 3+ messages in thread
From: Viacheslav Dubeyko @ 2015-03-23 18:16 UTC (permalink / raw)
To: htl10; +Cc: saproj, linux-fsdevel, akpm, aia21, viro, hch, sougata
On Mon, 2015-03-23 at 18:00 +0000, Hin-Tak Leung wrote:
> ------------------------------
> >
> >To be honest, I am not fully understand what is the case of the fix. As
> >a result, I can understand correctness of the fix. Could you describe
> >the issue and the fix in more details? Could you provide more clear
> >description of the use-case of such issue? Anyway, this fix requires in
> >more clear and detailed description.
>
> Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net>
>
> I think I understand the description, though I have not checked
> the code itself in detail (and the fat driver origin). The use
> of 'truncate' to illustrate the problem is a bit unfortunate,
> as the issue is not about making a file smaller, but larger,
> e.g. seek'ing beyond the end of a file
> to expand it. It should fail if one seeks too far
> and try to create a very large file, but it currently does
> not fail (or so it says), but results in an inconsistent file system.
>
> Hope this helps.
>
Description of the fix needs in correction because current description
doesn't provide enough details for clear understanding of the issue and
the fix. Currently, it's hard to realize the fix, from my point of view.
Thanks,
Vyacheslav Dubeyko.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-23 18:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-23 2:53 [PATCH] hfsplus: fix expand when not enough available space Sergei Antonov
2015-03-23 17:28 ` Viacheslav Dubeyko
[not found] <1427133643.76486.YahooMailBasic@web172302.mail.ir2.yahoo.com>
2015-03-23 18:16 ` Viacheslav Dubeyko
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).