From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1E03C3A5A9 for ; Mon, 4 May 2020 17:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD11721841 for ; Mon, 4 May 2020 17:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E8uXRnE+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730023AbgEDROf (ORCPT ); Mon, 4 May 2020 13:14:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36099 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730514AbgEDROf (ORCPT ); Mon, 4 May 2020 13:14:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588612474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e4U4fcN/pK7N2vY4Mne5ej9n14XUHHEQ4OsRfDbqy0E=; b=E8uXRnE+PXcgNrFQDf8fohk2vlu2IjJdCx/zD6utyvj/j/DGcJXWzKnOhi8nDHWXP08R0O fjGBKODsF9syeDGumSgJN5xlY19wwNgAOOHVzNImvP5n4xcQdf+ixxPdTk2n7RWR2vwfUW 9IEkLfQVRiLhxyCFA1JbR26PSIvGL3E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-u8C8a5BLMmaTOqWvrjo2nA-1; Mon, 04 May 2020 13:14:31 -0400 X-MC-Unique: u8C8a5BLMmaTOqWvrjo2nA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0E9C835B40; Mon, 4 May 2020 17:14:29 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-225.rdu2.redhat.com [10.10.118.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1704760F8D; Mon, 4 May 2020 17:14:26 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [RFC PATCH 46/61] cachefiles: Shape write requests From: David Howells To: Trond Myklebust , Anna Schumaker , Steve French , Jeff Layton Cc: dhowells@redhat.com, Matthew Wilcox , Alexander Viro , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 04 May 2020 18:14:26 +0100 Message-ID: <158861246621.340223.9118210695394840507.stgit@warthog.procyon.org.uk> In-Reply-To: <158861203563.340223.7585359869938129395.stgit@warthog.procyon.org.uk> References: <158861203563.340223.7585359869938129395.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.21 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org In cachefiles_shape_extent(), shape a write request to always write to the cache. The assumption is made that the caller has read the entire cache granule beforehand if necessary. Possibly this should be amended so that writes will only take place to granules that are marked present and granules that lie beyond the EOF. Signed-off-by: David Howells --- fs/cachefiles/content-map.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/fs/cachefiles/content-map.c b/fs/cachefiles/content-map.c index 13632c097248..2c45092465b6 100644 --- a/fs/cachefiles/content-map.c +++ b/fs/cachefiles/content-map.c @@ -71,7 +71,8 @@ static unsigned int cachefiles_shape_single(struct fscache_object *obj, extent->dio_block_size = CACHEFILES_DIO_BLOCK_SIZE; - if (object->content_info == CACHEFILES_CONTENT_SINGLE) { + if (!for_write && + object->content_info == CACHEFILES_CONTENT_SINGLE) { ret = FSCACHE_READ_FROM_CACHE; } else { eof = (i_size + PAGE_SIZE - 1) >> PAGE_SHIFT; @@ -128,13 +129,20 @@ unsigned int cachefiles_shape_extent(struct fscache_object *obj, granule = start / CACHEFILES_GRAN_PAGES; - /* If the content map didn't get expanded for some reason - simply - * ignore this granule. - */ - if (granule / 8 >= object->content_map_size) - return 0; + if (granule / 8 >= object->content_map_size) { + cachefiles_expand_content_map(object, i_size); + if (granule / 8 >= object->content_map_size) + return 0; + } - if (cachefiles_granule_is_present(object, granule)) { + if (for_write) { + /* Assume that the preparation to write involved preloading any + * bits of the cache that weren't to be written and filling any + * gaps that didn't end up being written. + */ + bend = end; + ret = FSCACHE_WRITE_TO_CACHE; + } else if (cachefiles_granule_is_present(object, granule)) { /* The start of the requested extent is present in the cache - * restrict the returned extent to the maximum length of what's * available.