From patchwork Tue Jun 7 17:29:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 858242 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p57HTn1K019764 for ; Tue, 7 Jun 2011 17:29:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755722Ab1FGR3m (ORCPT ); Tue, 7 Jun 2011 13:29:42 -0400 Received: from int-mailstore01.merit.edu ([207.75.116.232]:53745 "EHLO int-mailstore01.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932074Ab1FGR3b (ORCPT ); Tue, 7 Jun 2011 13:29:31 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by int-mailstore01.merit.edu (Postfix) with ESMTP id 51652305CF58; Tue, 7 Jun 2011 13:29:31 -0400 (EDT) X-Virus-Scanned: amavisd-new at int-mailstore01.merit.edu Received: from int-mailstore01.merit.edu ([127.0.0.1]) by localhost (int-mailstore01.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A-V2NjEAYEy1; Tue, 7 Jun 2011 13:29:30 -0400 (EDT) Received: from merit.edu (host-17.subnet-17.med.umich.edu [141.214.17.17]) by int-mailstore01.merit.edu (Postfix) with ESMTPSA id B80613055B74; Tue, 7 Jun 2011 13:29:30 -0400 (EDT) Date: Tue, 7 Jun 2011 13:29:29 -0400 From: Jim Rees To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Subject: [PATCH 31/88] pnfsblock: write_end_cleanup Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Jun 2011 17:29:49 +0000 (UTC) From: Fred Isaman Ensure all pages in block are marked for initialization if needed. [pnfsblock: Update to 2.6.29] Signed-off-by: Fred Isaman Signed-off-by: Benny Halevy --- fs/nfs/blocklayout/blocklayout.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index f4851c1..af26bcc 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -835,6 +835,64 @@ bl_write_end(struct inode *inode, struct page *page, loff_t pos, return 0; } +/* Return any memory allocated to fsdata->private, and take advantage + * of no page locks to mark pages noted in write_begin as needing + * initialization. + */ +static void +bl_write_end_cleanup(struct file *filp, struct pnfs_fsdata *fsdata) +{ + struct page *page; + pgoff_t index; + sector_t *pos; + struct address_space *mapping = filp->f_mapping; + struct pnfs_fsdata *fake_data; + + if (!fsdata) + return; + pos = fsdata->private; + if (!pos) + return; + dprintk("%s enter with pos=%llu\n", __func__, (u64)(*pos)); + for (; *pos != ~0; pos++) { + index = *pos >> (PAGE_CACHE_SHIFT - 9); + /* XXX How do we properly deal with failures here??? */ + page = grab_cache_page_write_begin(mapping, index, 0); + if (!page) { + printk(KERN_ERR "%s BUG BUG BUG NoMem\n", __func__); + continue; + } + dprintk("%s: Examining block page\n", __func__); + print_page(page); + if (!PageMappedToDisk(page)) { + /* XXX How do we properly deal with failures here??? */ + dprintk("%s Marking block page\n", __func__); + init_page_for_write(BLK_LSEG2EXT(fsdata->lseg), page, + PAGE_CACHE_SIZE, PAGE_CACHE_SIZE, + NULL); + print_page(page); + fake_data = kzalloc(sizeof(*fake_data), GFP_KERNEL); + if (!fake_data) { + printk(KERN_ERR "%s BUG BUG BUG NoMem\n", + __func__); + unlock_page(page); + continue; + } + fake_data->ok_to_use_pnfs = 1; + fake_data->bypass_eof = 1; + mapping->a_ops->write_end(filp, mapping, + index << PAGE_CACHE_SHIFT, + PAGE_CACHE_SIZE, + PAGE_CACHE_SIZE, + page, fake_data); + /* Note fake_data is freed by nfs_write_end */ + } else + unlock_page(page); + } + kfree(fsdata->private); + fsdata->private = NULL; +} + static ssize_t bl_get_stripesize(struct pnfs_layout_type *lo) { @@ -880,6 +938,7 @@ static struct layoutdriver_io_operations blocklayout_io_operations = { .write_pagelist = bl_write_pagelist, .write_begin = bl_write_begin, .write_end = bl_write_end, + .write_end_cleanup = bl_write_end_cleanup, .alloc_layout = bl_alloc_layout, .free_layout = bl_free_layout, .alloc_lseg = bl_alloc_lseg,