From patchwork Mon May 9 16:41:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Amir G." X-Patchwork-Id: 94806 X-Patchwork-Delegate: tytso@mit.edu 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 08FB5B6F1E for ; Tue, 10 May 2011 02:43:53 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587Ab1EIQnv (ORCPT ); Mon, 9 May 2011 12:43:51 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:33538 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753569Ab1EIQnu (ORCPT ); Mon, 9 May 2011 12:43:50 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so4026020wya.19 for ; Mon, 09 May 2011 09:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=ACl6TlC6Xs5C+680DCf9rwIJ71f2syP/SGmD1/6t100=; b=bIud38+yld5ZFSaNNxqz0DQMpFFAVj3QOOxBaYY2bNPWP5MScR8O2hDLW3jB/rjxy9 aVHyzdFyQCL1Pvn5WzuZVLaYrZSyM8y+kfBkAqR+ZKjO/iCaozL3obsODnUvLqN5TlAr mp0yZyztVOcXK95JUmi7C2NOh1Y497ZfW9CdM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=bOn3KTHDCXLeAm8MLAwVgjYsLNcRkXRJvIPwCGBq6RNBl6oE5rfWRa787n09NnYiur EvpPisUNyke1ezXcrTCDFpzR0FR2mZ/vTpRlaN7O7F/rOeGkBee/AFrdgFbzbQfTMQz2 giQ9KsxYYfc98J1pvrhPxPCgKeYx2iLFqSVt0= Received: by 10.227.198.197 with SMTP id ep5mr7542548wbb.33.1304959429757; Mon, 09 May 2011 09:43:49 -0700 (PDT) Received: from localhost.localdomain (bzq-79-179-43-50.red.bezeqint.net [79.179.43.50]) by mx.google.com with ESMTPS id o23sm2034877wbc.27.2011.05.09.09.43.47 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 May 2011 09:43:49 -0700 (PDT) From: amir73il@users.sourceforge.net To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Amir Goldstein , Yongqiang Yang Subject: [PATCH RFC 14/30] ext4: snapshot block operations Date: Mon, 9 May 2011 19:41:32 +0300 Message-Id: <1304959308-11122-15-git-send-email-amir73il@users.sourceforge.net> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1304959308-11122-1-git-send-email-amir73il@users.sourceforge.net> References: <1304959308-11122-1-git-send-email-amir73il@users.sourceforge.net> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Amir Goldstein Core API of special snapshot file block operations. The argument @create to the function ext4_getblk() is re-interpreted as a snapshot block command argument. The old argument values 0(=read) and 1(=create) preserve the original behavior of the function. The bit field h_cowing in the current transaction handle is used to prevent COW recursions. Signed-off-by: Amir Goldstein Signed-off-by: Yongqiang Yang --- fs/ext4/ext4.h | 10 ++++++++++ fs/ext4/ext4_jbd2.h | 3 +++ fs/ext4/inode.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 8f59322..c7fd33e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -557,6 +557,16 @@ struct ext4_new_group_data { * if EXT4_GET_BLOCKS_CREATE is not set, return REMAP flags. */ #define EXT4_GET_BLOCKS_MOVE_ON_WRITE 0x0100 +/* + * snapshot_map_blocks() flags passed to ext4_map_blocks() for mapping + * blocks to snapshot. + */ + /* handle COW race conditions */ +#define EXT4_GET_BLOCKS_COW 0x200 + /* allocate only indirect blocks */ +#define EXT4_GET_BLOCKS_MOVE 0x400 + /* bypass journal and sync allocated indirect blocks directly to disk */ +#define EXT4_GET_BLOCKS_SYNC 0x800 /* * Flags used by ext4_free_blocks diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index e0fef0d..79b6594 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -173,6 +173,9 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line, #define ext4_handle_dirty_super(handle, sb) \ __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb)) +#define trace_cow_add(handle, name, num) +#define trace_cow_inc(handle, name) + handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 425dabb..ba66545 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1600,8 +1600,8 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, map.m_lblk = block; map.m_len = 1; - err = ext4_map_blocks(handle, inode, &map, - create ? EXT4_GET_BLOCKS_CREATE : 0); + /* passing SNAPMAP flags on create argument */ + err = ext4_map_blocks(handle, inode, &map, create); if (err < 0) *errp = err;