From: Andrew Morton <akpm@zip.com.au>
To: Oleg Drokin <green@namesys.com>
Cc: marcelo@conectiva.com.br, linux-kernel@vger.kernel.org,
reiserfs-dev@namesys.com
Subject: Re: [PATCH] expanding truncate
Date: Wed, 02 Jan 2002 23:50:29 -0800 [thread overview]
Message-ID: <3C340D45.32E1D88B@zip.com.au> (raw)
In-Reply-To: <20020103102128.A2625@namesys.com>
Oleg Drokin wrote:
>
> Hello!
>
> This patch makes sure that indirect pointers for holes are correctly filled in by zeroes at
> hole-creation time. (Author is Chris Mason. fs/buffer.c part (generic_cont_expand) were written by
> Alexander Viro)
>
> Please apply.
>
> ...
>
Please. Do not add new library functions to the kernel with
no descriptive commentary at all. We really need to get past
that stage.
What is this function supposed to do? It appears that if
the page at `size' is not in cache, we write uninitialised
data into the file.
--- linux-2.4.18-pre1/fs/buffer.c.orig Thu Jan 3 10:02:03 2002
+++ linux-2.4.18-pre1/fs/buffer.c Thu Jan 3 10:09:24 2002
@@ -1760,6 +1760,46 @@
return 0;
}
+int generic_cont_expand(struct inode *inode, loff_t size)
+{
+ struct address_space *mapping = inode->i_mapping;
+ struct page *page;
+ unsigned long index, offset, limit;
+ int err;
+
+ limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
+ if (limit != RLIM_INFINITY) {
+ if (size > limit) {
+ send_sig(SIGXFSZ, current, 0);
+ size = limit;
+ }
+ }
+ offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */
+
+ /* ugh. in prepare/commit_write, if from==to==start of block, we
+ ** skip the prepare. make sure we never send an offset for the start
+ ** of a block
+ */
+ if ((offset & (inode->i_sb->s_blocksize - 1)) == 0) {
+ offset++ ;
+ }
+ index = size >> PAGE_CACHE_SHIFT;
+ err = -ENOMEM;
+ page = grab_cache_page(mapping, index);
+ if (!page)
+ goto out;
+ err = mapping->a_ops->prepare_write(NULL, page, offset, offset);
+ if (!err) {
+ err = mapping->a_ops->commit_write(NULL, page, offset, offset);
+ }
+ UnlockPage(page);
+ page_cache_release(page);
+ if (err > 0)
+ err = 0;
+out:
+ return err;
+}
+
next prev parent reply other threads:[~2002-01-03 7:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-03 7:21 [PATCH] expanding truncate Oleg Drokin
2002-01-03 7:50 ` Andrew Morton [this message]
2002-01-03 12:25 ` Alan Cox
2002-01-03 12:25 ` Oleg Drokin
2002-01-03 16:17 ` Alexander Viro
2002-01-04 17:33 ` [reiserfs-dev] " Chris Mason
2002-01-11 20:52 ` Chris Mason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C340D45.32E1D88B@zip.com.au \
--to=akpm@zip.com.au \
--cc=green@namesys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=reiserfs-dev@namesys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox