Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3085286pxb; Mon, 18 Oct 2021 07:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJgwDKLC6RFRsN5RgkRJu4YHfbK0vcB/mlH0COft8uevZUERdsm8nu9vUwBNDvUDPCYCYF X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr47905295pjb.139.1634569148539; Mon, 18 Oct 2021 07:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569148; cv=none; d=google.com; s=arc-20160816; b=Od9ZbeD1zn12qYWocj2LziwqdH2GE+BsomVO+a88wP28emNGonu8LYu+pb/bVh0/NH sxAvgDyKCmcZDqBcu8X8ZygSUEcarYIKakQ9MRQvBaL5L2fEeFAfO/m3MnwXchNbWkVN r4Jx3R6rwZAWdUWOrx0ZNmu+tMP8miUlCC0F2NPr1lLXonsMmEinT2rFgULAlzJzTuKz quB5EJhoXV51mXpvULMtX4yDWLtbeTXlIlLwOB26RowoH1dce8RDjKDm5A5kTfmkPp92 jalWEOvwgLoFEUxdAmWO8wOLA/Drqwrn7up0HRBDoBrNgLdb6zlCKz0luRaxMn2u1SYD zAvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=K5FTLf3BYt9yC5gnmuuFov8Yi7OVdM9eRPeEUyTv68E=; b=Ey5HDLi3+Fg8mrsX87Lk1mQz+1mAIc7Ds7XLOfWidnFd//rLXHUqO/Fw6OF38Uk1SU bsVQr94ROq6GwquO2P7o3QfRkpZWvKgRz/LaYKoirT5v7PcZjAB7y936KqU6VdQegPv4 9S3cG8xCkheGgUstQjqXRAYSFGAgJp51r+71el/SB8DNEjHwbGs4kPerGBGrmi6nzU4Z Kavgkr2JUzGyYae3X3Hhm8x9i4n9VQkEa32hW+k4Q8adFmu8iK+LqpWqHNA43YirmFoM hVHz1WN6b1prz8t61UAvtNnnFwKJEWXBQ87WNs8j9Ivs00CU4nHgRzWCgJld1yuElDN9 FJTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B0ELvZRJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si26099802pfl.29.2021.10.18.07.58.55; Mon, 18 Oct 2021 07:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B0ELvZRJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232773AbhJRPBE (ORCPT + 99 others); Mon, 18 Oct 2021 11:01:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30998 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232473AbhJRPBD (ORCPT ); Mon, 18 Oct 2021 11:01:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634569132; 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=K5FTLf3BYt9yC5gnmuuFov8Yi7OVdM9eRPeEUyTv68E=; b=B0ELvZRJNt5Rq7J2VGIl7cEtBzP6PNlKDDBZlBGT7YWUJQAYRLsSJNffwq6p2kDVQkzJGr H6MIDfD2gl09p1zb370I+F27yuaIDjbDhz5pXI8n8iJx98kfu6KiBsZuHlovrT8ApsMXf4 DIDWO2Bh7l/KSgYmX9L5oYEw+9FcxZY= 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-415-j8jdinTONVS7GUILmqYu9Q-1; Mon, 18 Oct 2021 10:58:48 -0400 X-MC-Unique: j8jdinTONVS7GUILmqYu9Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E3E991278; Mon, 18 Oct 2021 14:58:46 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B9076788F; Mon, 18 Oct 2021 14:58:05 +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: [PATCH 30/67] cachefiles: Round the cachefile size up to DIO block size From: David Howells To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , 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, 18 Oct 2021 15:58:04 +0100 Message-ID: <163456908429.2614702.18199815281243741948.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 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.16 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Round the size of a cachefile up to DIO block size so that we can always read back the last partial page of a file using direct I/O. Signed-off-by: David Howells --- fs/cachefiles/bind.c | 3 ++- fs/cachefiles/interface.c | 2 ++ fs/cachefiles/internal.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index af7386ad14af..4ea8c93e14d8 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c @@ -126,7 +126,8 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) !d_backing_inode(root)->i_op->mkdir || !(d_backing_inode(root)->i_opflags & IOP_XATTR) || !root->d_sb->s_op->statfs || - !root->d_sb->s_op->sync_fs) + !root->d_sb->s_op->sync_fs || + root->d_sb->s_blocksize > PAGE_SIZE) goto error_unsupported; ret = -EROFS; diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 8f98e5c27d66..3e678ab14c85 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c @@ -268,6 +268,7 @@ static int cachefiles_attr_changed(struct cachefiles_object *object) int ret; ni_size = object->cookie->object_size; + ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE); _enter("{OBJ%x},[%llu]", object->debug_id, (unsigned long long) ni_size); @@ -346,6 +347,7 @@ static void cachefiles_invalidate_object(struct cachefiles_object *object) cachefiles_trunc_invalidate); ret = vfs_truncate(&file->f_path, 0); if (ret == 0) { + ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE); trace_cachefiles_trunc(object, file_inode(file), 0, ni_size, cachefiles_trunc_set_size); diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 4705f968e661..ff00c5249f4f 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -19,6 +19,8 @@ #include #include +#define CACHEFILES_DIO_BLOCK_SIZE 4096 + struct cachefiles_cache; struct cachefiles_object;