All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: "Aneesh Kumar K. V." <aneesh.kumar@linux.vnet.ibm.com>
Cc: linux-ext4@vger.kernel.org
Subject: write/write/fallocate quota leakage
Date: Thu, 03 Jun 2010 12:21:01 +0400	[thread overview]
Message-ID: <87typk1q8i.fsf@openvz.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

Recently one "write vs fallocate" quota leakage was fixed, but
not completely. It is still possible if uninitialized extent which
covers several delay allocated regions converted to initialized one.

Take a look at test-case attached.
The issue is clear enough, but I don't have a good solution for now.
Off course we can add one more restriction to zeroout logic, but this is
unproductive way because we have to keep zeroout logic simple as possible.

Aneesh, do you have any sound ideas?


[-- Attachment #2: falloc_opt.c --]
[-- Type: text/plain, Size: 1171 bytes --]

/* EXT4 delalloc reservation leakage testcase
 * To make that leackage more verbose please apply following patch
 * http://download.openvz.org/~dmonakhov/junk/ext4-sanity-check.patch
 */
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	loff_t len, offset;
	int fd, ret;
	char buf[81920];
	if (argc != 2) {
		printf("Usage: %s <fname>\n", argv[0]);
		return 1;
	}
	fd = open(argv[1], O_CREAT|O_RDWR, 0777);
	ftruncate(fd, 40960);
	fsync(fd);
	ret = pwrite(fd, buf, 4096, 0);
	if (ret != 4096) {
		perror("write failed");
		return 1;
	}
	/* Leve one page gap between dirty pages */
	ret = pwrite(fd, buf, 8192, 8192);
	if (ret != 8192) {
		perror("write failed");
		return 1;
	}
	/* Create uninitialized extent */
	ret = fallocate(fd, 0x1, 0, 4096*5);
	if (ret) {
		perror("fallocate failed");
		return 1;
	}
	/* Force block allocation.
	 * Uninitialized extent will be converted to initialized one
	 * during ext4_map_blocks() on writing first pages set.
	 * Later second pages set will discover what blocks are already
	 * initialized, so reservation for that pages will leak.
	 */
	fsync(fd);
	return 0;
}

             reply	other threads:[~2010-06-03  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03  8:21 Dmitry Monakhov [this message]
2010-06-04  9:03 ` write/write/fallocate quota leakage Aneesh Kumar K. V

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=87typk1q8i.fsf@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.