From patchwork Mon Aug 5 19:44:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 264767 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E5A302C00AC for ; Tue, 6 Aug 2013 05:45:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754860Ab3HEToS (ORCPT ); Mon, 5 Aug 2013 15:44:18 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:55509 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754849Ab3HEToQ (ORCPT ); Mon, 5 Aug 2013 15:44:16 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc17so3743383pbc.18 for ; Mon, 05 Aug 2013 12:44:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=xsDTwYyU9gUltZpjfux7PjdpfKWZWWboonWUvMG/2+k=; b=QeAaRmYEPAB6CBz17kd6iAi9JDRyzIHDQv7j4P9q73+q5/ui3QM9BpJ7ooyLPbR9oE o4ThW35Q0o1uxpgu/2ScfKEKl0k4/BNWKqsxOCGrOSYCYE4SFayF4OYBsfg77MK1Awk4 r1FZC9hnSwcxPiBj7oI9lUf6z8uwI1jJ8kXT22VtSQdagMw/HDhbOfNd2RQYVL8KPZdQ p5n4JyHlkESDF9fE+SkSdtSNY3+PiYrVuWO6XdlZfESCD4R0hnFSD/JQqy0pz8YnyQl9 BeY+WLKjBa9ziFTWda4M9E1nLyfRRflPbjvhS7csiGS5wtlqFdh4xc7zs0joL8tOzpSa 7NCA== X-Received: by 10.68.239.42 with SMTP id vp10mr23810425pbc.164.1375731855925; Mon, 05 Aug 2013 12:44:15 -0700 (PDT) Received: from localhost (50-76-60-73-ip-static.hfc.comcastbusiness.net. [50.76.60.73]) by mx.google.com with ESMTPSA id kc8sm662474pbc.18.2013.08.05.12.44.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 Aug 2013 12:44:15 -0700 (PDT) From: Andy Lutomirski To: linux-mm@kvack.org, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andy Lutomirski Subject: [RFC 3/3] ext4: Implement willwrite for the delalloc case Date: Mon, 5 Aug 2013 12:44:01 -0700 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQmjbscSLBcGk+i0uU3y8P8Gpqtzva+X/CNm4UgySaYSDLHJFoN8cUTkxHkPtOXNR0Y1bNey Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Signed-off-by: Andy Lutomirski --- fs/ext4/ext4.h | 2 ++ fs/ext4/file.c | 1 + fs/ext4/inode.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b577e45..be7308a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2103,6 +2103,8 @@ extern int ext4_block_zero_page_range(handle_t *handle, extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, loff_t lstart, loff_t lend); extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); +extern long ext4_willwrite(struct vm_area_struct *vma, + unsigned long start, unsigned long end); extern qsize_t *ext4_get_reserved_space(struct inode *inode); extern void ext4_da_update_reserve_space(struct inode *inode, int used, int quota_claim); diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 6f4cc56..159226f 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -201,6 +201,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov, static const struct vm_operations_struct ext4_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = ext4_page_mkwrite, + .willwrite = ext4_willwrite, .remap_pages = generic_file_remap_pages, }; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ba33c67..c49e36b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5101,3 +5101,25 @@ out: sb_end_pagefault(inode->i_sb); return ret; } + +long ext4_willwrite(struct vm_area_struct *vma, + unsigned long start, unsigned long end) +{ + int ret = 0; + struct file *file = vma->vm_file; + struct inode *inode = file_inode(file); + int retries = 0; + + /* We only support the delalloc case */ + if (test_opt(inode->i_sb, DELALLOC) && + !ext4_should_journal_data(inode) && + !ext4_nonda_switch(inode->i_sb)) { + do { + ret = block_willwrite(vma, start, end, + ext4_da_get_block_prep); + } while (ret == -ENOSPC && + ext4_should_retry_alloc(inode->i_sb, &retries)); + } + + return ret; +}