Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1617911 > unrolled thread
| Started by | Dmitry Monakhov <dmonakhov@openvz.org> |
|---|---|
| First post | 2017-04-06 14:10 +0200 |
| Last post | 2017-04-06 18:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 5/5] block: truncate page cache only when necessary on fallocate Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-06 14:10 +0200
Re: [PATCH 5/5] block: truncate page cache only when necessary on fallocate Christoph Hellwig <hch@infradead.org> - 2017-04-06 17:50 +0200
Re: [PATCH 5/5] block: truncate page cache only when necessary on fallocate Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-06 18:00 +0200
| From | Dmitry Monakhov <dmonakhov@openvz.org> |
|---|---|
| Date | 2017-04-06 14:10 +0200 |
| Subject | [PATCH 5/5] block: truncate page cache only when necessary on fallocate |
| Message-ID | <tteoG-8jD-19@gated-at.bofh.it> |
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/block_dev.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 2eca00e..f4b13e1 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -2075,7 +2075,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
{
struct block_device *bdev = I_BDEV(bdev_file_inode(file));
struct request_queue *q = bdev_get_queue(bdev);
- struct address_space *mapping;
+ struct address_space *mapping = bdev->bd_inode->i_mapping;
loff_t end = start + len - 1;
loff_t isize;
int error;
@@ -2102,13 +2102,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
if ((start | len) & (bdev_logical_block_size(bdev) - 1))
return -EINVAL;
- /* Invalidate the page cache, including dirty pages. */
- mapping = bdev->bd_inode->i_mapping;
- truncate_inode_pages_range(mapping, start, end);
-
switch (mode) {
case FALLOC_FL_ZERO_RANGE:
case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
+ truncate_inode_pages_range(mapping, start, end);
error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
GFP_KERNEL, false);
break;
@@ -2116,12 +2113,14 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
/* Only punch if the device can do zeroing discard. */
if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data)
return -EOPNOTSUPP;
+ truncate_inode_pages_range(mapping, start, end);
error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
GFP_KERNEL, 0);
break;
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
if (!blk_queue_discard(q))
return -EOPNOTSUPP;
+ truncate_inode_pages_range(mapping, start, end);
error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
GFP_KERNEL, 0);
break;
--
2.9.3
[toc] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-04-06 17:50 +0200 |
| Subject | Re: [PATCH 5/5] block: truncate page cache only when necessary on fallocate |
| Message-ID | <tthPz-2yp-1@gated-at.bofh.it> |
| In reply to | #1617911 |
why?
On Thu, Apr 06, 2017 at 04:02:49PM +0400, Dmitry Monakhov wrote:
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
> fs/block_dev.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 2eca00e..f4b13e1 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -2075,7 +2075,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
> {
> struct block_device *bdev = I_BDEV(bdev_file_inode(file));
> struct request_queue *q = bdev_get_queue(bdev);
> - struct address_space *mapping;
> + struct address_space *mapping = bdev->bd_inode->i_mapping;
> loff_t end = start + len - 1;
> loff_t isize;
> int error;
> @@ -2102,13 +2102,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
> if ((start | len) & (bdev_logical_block_size(bdev) - 1))
> return -EINVAL;
>
> - /* Invalidate the page cache, including dirty pages. */
> - mapping = bdev->bd_inode->i_mapping;
> - truncate_inode_pages_range(mapping, start, end);
> -
> switch (mode) {
> case FALLOC_FL_ZERO_RANGE:
> case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
> + truncate_inode_pages_range(mapping, start, end);
> error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
> GFP_KERNEL, false);
> break;
> @@ -2116,12 +2113,14 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
> /* Only punch if the device can do zeroing discard. */
> if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data)
> return -EOPNOTSUPP;
> + truncate_inode_pages_range(mapping, start, end);
> error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
> GFP_KERNEL, 0);
> break;
> case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
> if (!blk_queue_discard(q))
> return -EOPNOTSUPP;
> + truncate_inode_pages_range(mapping, start, end);
> error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
> GFP_KERNEL, 0);
> break;
> --
> 2.9.3
>
---end quoted text---
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Monakhov <dmonakhov@openvz.org> |
|---|---|
| Date | 2017-04-06 18:00 +0200 |
| Message-ID | <tthZh-2Gn-27@gated-at.bofh.it> |
| In reply to | #1618119 |
Christoph Hellwig <hch@infradead.org> writes:
> why?
because it is not good thing to truncate page cache and fiew lines later
realize that feature is not supported !blk_queue_discard(q) and return ENOTSUPP.
Event more: if mode == FALLOC_FL_KEEP_SIZE then we do nothing and
return ENOTSUPP unconditionally.
IMHO (mode == FALLOC_FL_KEEP_SIZE) is sane API for thin-provision blkdevs
to preallocate space in advance. Nobody use it at the moment, but it may
be usefull in future.
>
> On Thu, Apr 06, 2017 at 04:02:49PM +0400, Dmitry Monakhov wrote:
>> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
>> ---
>> fs/block_dev.c | 9 ++++-----
>> 1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/block_dev.c b/fs/block_dev.c
>> index 2eca00e..f4b13e1 100644
>> --- a/fs/block_dev.c
>> +++ b/fs/block_dev.c
>> @@ -2075,7 +2075,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>> {
>> struct block_device *bdev = I_BDEV(bdev_file_inode(file));
>> struct request_queue *q = bdev_get_queue(bdev);
>> - struct address_space *mapping;
>> + struct address_space *mapping = bdev->bd_inode->i_mapping;
>> loff_t end = start + len - 1;
>> loff_t isize;
>> int error;
>> @@ -2102,13 +2102,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>> if ((start | len) & (bdev_logical_block_size(bdev) - 1))
>> return -EINVAL;
>>
>> - /* Invalidate the page cache, including dirty pages. */
>> - mapping = bdev->bd_inode->i_mapping;
>> - truncate_inode_pages_range(mapping, start, end);
>> -
>> switch (mode) {
>> case FALLOC_FL_ZERO_RANGE:
>> case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
>> + truncate_inode_pages_range(mapping, start, end);
>> error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
>> GFP_KERNEL, false);
>> break;
>> @@ -2116,12 +2113,14 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>> /* Only punch if the device can do zeroing discard. */
>> if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data)
>> return -EOPNOTSUPP;
>> + truncate_inode_pages_range(mapping, start, end);
>> error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
>> GFP_KERNEL, 0);
>> break;
>> case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
>> if (!blk_queue_discard(q))
>> return -EOPNOTSUPP;
>> + truncate_inode_pages_range(mapping, start, end);
>> error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
>> GFP_KERNEL, 0);
>> break;
>> --
>> 2.9.3
>>
> ---end quoted text---
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web