From patchwork Tue Jun 11 01:12:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 17748 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4C49125E5D for ; Tue, 11 Jun 2013 01:12:37 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 1sf2630617qec.3 for ; Mon, 10 Jun 2013 18:12:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=0ME0TlPiK5Xn713YmT0+VFKS2XEZJ8JPmCu+OB8f6E8=; b=aE5cvFDBChhm/Wha7BaSdep4bfFZmagjm/9b2uH+7FbbEIM7/OvMbVi9O/IGvNMxCt imHVqIMMMkbUYZt6dc0D2O1spFU3aZHBx+TBihBvdm27UeLnxkIq5g7Tgzg6iZ54a7pY 0jwV6i7G3ftgCrk5acxDzJDpEEifA9U1w5WONHuvJLaV/vmhCh9FtTcsor0r6ViOGSrh rGKldt3D9AKYOw1z0QWOEKo59F6b9XwW9EJPm2ujsjel8ZI2Q95Hl/kPGz9a0gGsYnF/ qjX+YA5X11/B9T2bAm5DfbvBeei42P7yHDP/l4RI240j5VPayOVsDy8q23i/XBMcaQo5 wc/g== X-Received: by 10.224.42.141 with SMTP id s13mr9694034qae.3.1370913156954; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.161 with SMTP id kv1ls2052832qeb.74.gmail; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) X-Received: by 10.52.23.10 with SMTP id i10mr809253vdf.121.1370913156712; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id o5si6146867vea.13.2013.06.10.18.12.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id gf11so2880522vcb.39 for ; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr6107307vdj.8.1370913156528; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp89595vcb; Mon, 10 Jun 2013 18:12:36 -0700 (PDT) X-Received: by 10.66.146.7 with SMTP id sy7mr16624784pab.16.1370913155152; Mon, 10 Jun 2013 18:12:35 -0700 (PDT) Received: from mail-pb0-x234.google.com (mail-pb0-x234.google.com [2607:f8b0:400e:c01::234]) by mx.google.com with ESMTPS id rs6si5805667pbc.272.2013.06.10.18.12.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:35 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c01::234 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c01::234; Received: by mail-pb0-f52.google.com with SMTP id xa12so7867429pbc.11 for ; Mon, 10 Jun 2013 18:12:34 -0700 (PDT) X-Received: by 10.68.213.162 with SMTP id nt2mr11924571pbc.179.1370913154766; Mon, 10 Jun 2013 18:12:34 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id qe10sm9802489pbb.2.2013.06.10.18.12.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:34 -0700 (PDT) From: John Stultz To: minchan@kernel.org Cc: dgiani@mozilla.com, John Stultz Subject: [PATCH 02/13] vrange: Add vrange support for file address_spaces Date: Mon, 10 Jun 2013 18:12:08 -0700 Message-Id: <1370913139-9320-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370913139-9320-1-git-send-email-john.stultz@linaro.org> References: <1370913139-9320-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQmjw6KR2C2LMLc9vk3UfCErWmS6Fty1iaRX2Gsa1RWHf3NKVy0v0L5AvwnNAFjZSWyzIs3q X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Modify address_space structures to be able to store vrange trees. This includes logic to clear all volatile ranges when the last file handle is closed. Signed-off-by: John Stultz Signed-off-by: Minchan Kim [jstultz: Major refactoring of the code] Signed-off-by: John Stultz --- fs/file_table.c | 5 +++++ fs/inode.c | 2 ++ include/linux/fs.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index cd4d87a..94e2cd3 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -244,6 +245,10 @@ static void __fput(struct file *file) file->f_op->fasync(-1, file, 0); } ima_file_free(file); + + /* drop all vranges on last close */ + vrange_root_cleanup(&inode->i_mapping->vroot); + if (file->f_op && file->f_op->release) file->f_op->release(inode, file); security_file_free(file); diff --git a/fs/inode.c b/fs/inode.c index 00d5fc3..bf32780 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -17,6 +17,7 @@ #include #include /* for inode_has_buffers */ #include +#include #include "internal.h" /* @@ -350,6 +351,7 @@ void address_space_init_once(struct address_space *mapping) spin_lock_init(&mapping->private_lock); mapping->i_mmap = RB_ROOT; INIT_LIST_HEAD(&mapping->i_mmap_nonlinear); + vrange_root_init(&mapping->vroot, VRANGE_FILE); } EXPORT_SYMBOL(address_space_init_once); diff --git a/include/linux/fs.h b/include/linux/fs.h index 43db02e..1cbed73 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -411,6 +412,7 @@ struct address_space { struct rb_root i_mmap; /* tree of private and shared mappings */ struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ struct mutex i_mmap_mutex; /* protect tree, count, list */ + struct vrange_root vroot; /* Protected by tree_lock together with the radix tree */ unsigned long nrpages; /* number of total pages */ pgoff_t writeback_index;/* writeback starts here */