linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Amit K. Arora" <aarora@linux.vnet.ibm.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-ext4@vger.kernel.org
Cc: xfs@oss.sgi.com
Subject: [PATCH 6/7] ext4: support new modes in ext4
Date: Wed, 11 Jul 2007 01:54:41 +0530	[thread overview]
Message-ID: <20070710202441.GF8797@amitarora.in.ibm.com> (raw)
In-Reply-To: <20070710201200.GA10255@amitarora.in.ibm.com>

From: Amit Arora <aarora@in.ibm.com>
Support new values of mode in ext4.

This patch supports new mode values/flags in ext4. With this patch ext4
will be able to support FALLOC_ALLOCATE and FALLOC_RESV_SPACE modes. Supporting
FALLOC_DEALLOCATE and FALLOC_UNRESV_SPACE fallocate modes in ext4 is a work for
future.

Signed-off-by: Amit Arora <aarora@in.ibm.com>

Index: linux-2.6.22/fs/ext4/extents.c
===================================================================
--- linux-2.6.22.orig/fs/ext4/extents.c
+++ linux-2.6.22/fs/ext4/extents.c
@@ -2453,8 +2453,9 @@ int ext4_ext_writepage_trans_blocks(stru
 /*
  * preallocate space for a file. This implements ext4's fallocate inode
  * operation, which gets called from sys_fallocate system call.
- * Currently only FA_ALLOCATE mode is supported on extent based files.
- * We may have more modes supported in future - like FA_DEALLOCATE, which
+ * Currently only FALLOC_ALLOCATE  and FALLOC_RESV_SPACE modes are supported on
+ * extent based files.
+ * We may have more modes supported in future - like FALLOC_DEALLOCATE, which
  * tells fallocate to unallocate previously (pre)allocated blocks.
  * For block-mapped files, posix_fallocate should fall back to the method
  * of writing zeroes to the required new blocks (the same behavior which is
@@ -2475,7 +2476,8 @@ long ext4_fallocate(struct inode *inode,
 	 * currently supporting (pre)allocate mode for extent-based
 	 * files _only_
 	 */
-	if (mode != FA_ALLOCATE || !(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
+	if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) ||
+		!(mode == FALLOC_ALLOCATE || mode == FALLOC_RESV_SPACE))
 		return -EOPNOTSUPP;
 
 	/* preallocation to directories is currently not supported */
@@ -2548,9 +2550,11 @@ retry:
 
 	/*
 	 * Time to update the file size.
-	 * Update only when preallocation was requested beyond the file size.
+	 * Update only when preallocation was requested beyond the file size
+	 * and when FALLOC_FL_KEEP_SIZE mode is not specified!
 	 */
-	if ((offset + len) > i_size_read(inode)) {
+	if (!(mode & FALLOC_FL_KEEP_SIZE) &&
+	    (offset + len) > i_size_read(inode)) {
 		if (ret > 0) {
 			/*
 			 * if no error, we assume preallocation succeeded

  parent reply	other threads:[~2007-07-10 20:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-10 20:12 [PATCH 0/7][TAKE6] fallocate system call Amit K. Arora
2007-07-10 20:18 ` [PATCH 1/7] manpage for fallocate Amit K. Arora
2007-07-10 21:37   ` Heikki Orsila
2007-07-11  9:12     ` Amit K. Arora
2007-07-11  1:37   ` Barry Naujok
2007-07-10 20:20 ` [PATCH 2/7] fallocate() implementation in i386, x86_64 and powerpc Amit K. Arora
2007-07-11  2:10   ` Stephen Rothwell
2007-07-11  4:59     ` Heiko Carstens
2007-07-11  8:11     ` Amit K. Arora
2007-07-12 12:56   ` David Patrick Quigley
2007-07-12 13:09     ` Amit K. Arora
2007-07-12 13:15     ` James Morris
2007-07-10 20:21 ` [PATCH 3/7] support new modes in fallocate Amit K. Arora
2007-07-10 20:22 ` [PATCH 4/7] ext4: fallocate support in ext4 Amit K. Arora
2007-07-10 20:23 ` [PATCH 5/7] ext4: write support for preallocated blocks Amit K. Arora
2007-07-10 20:24 ` Amit K. Arora [this message]
2007-07-10 20:26 ` [PATCH 7/7] ext4: change for better extent-to-group alignment Amit K. Arora

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=20070710202441.GF8797@amitarora.in.ibm.com \
    --to=aarora@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.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;
as well as URLs for NNTP newsgroup(s).