Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10486853ybi; Thu, 25 Jul 2019 00:09:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGR5aspBvzeiYNCFI/GWfSuPS2Yu6PVpzwOZP3YJihEY1U1BIoOARNUAf65wroS9jD0VxT X-Received: by 2002:a62:e515:: with SMTP id n21mr15390626pff.186.1564038597542; Thu, 25 Jul 2019 00:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564038597; cv=none; d=google.com; s=arc-20160816; b=xmMXIrUsc/ODNa2ar3tIx1/AHvz9HbeTPGdTOu0r3M5JY/Q5jLG+2OmTVQ76imaDPa kwKYnXt2dz6DOU3UlqydrOsBrbc2yQqSkY9kcAOpgZ7I+TrKQ5up3fqWLMB0t6LGP+92 8ffvunatKOER4rIzs1dKe0oUTtaX4Oq1LeAkl6UfQFRdp2d08OMgyOOXTj3GS+1H1sTU FacrZxxsS67m0uGy6bmQtDKLQgJXmHheYZBC8iIRWmJ6lEbe/3nkPMy8nv4sQgq5HQCO HIgg+xqG11YhLDSFGYgjwWEoTu3c60T83vlY5FhxY4N47YaXz7et25YSOiXlUn71NIdx bR7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KrQ7ATsPC79czmdpHFMybmF8eWNcqZZ2l6ec68AExfA=; b=idmSL1dvyqRXROfh+D5lmWnSV6xEoyhoCNPExjYMnUpwVJS4LOujkmWebCpZ5J29yp wP+wT21QJoV2zbHBxa+DGZ2KWy/DLfu/cyPKwC6m/KSGtmTVPr46utZv5V1DuObCOOXV F3/pKWbEWWkzKp8j97G12+Fjpj/XdZ+VenDhbYb4kwPgmO1+Er1nN/KjODGTpf5RdkxK WGvPRwZlU4vtWksgg8FrBcGXo2hwVuKuP3pKOsYTXqDF7IqClAH1zV3hFaFWh5wpqcbP qg4WsMKfe82a5itpHjMPLQbavrNFbaLBoHU5Cjibp6AxgC2S3B9S7htF+xGzuXkn2hW6 AnZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pynl8u9K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q199si15566380pfq.112.2019.07.25.00.09.42; Thu, 25 Jul 2019 00:09:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pynl8u9K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404896AbfGXT5V (ORCPT + 99 others); Wed, 24 Jul 2019 15:57:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:42542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404919AbfGXT5U (ORCPT ); Wed, 24 Jul 2019 15:57:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB5FE205C9; Wed, 24 Jul 2019 19:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998239; bh=AWiRpDhUWe3D66QtUkg0pgkGRfMqsc9N6RztAG8uWYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pynl8u9KDEIbTq2Cakdp64AhNcZwRMVVGGdVwD+9iWfh8V4FeQ64DrDSWl6lnwlSs XhKTlPhE0zLZoDxKCqOngdcf08/K7sMwbuzDDxBanpO7C4eb66xTOaSUKQmKwbgExM 1RYGah48K3dawGooqgLDwy1e/PR8rugXD1azmMc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luis Henriques , Jeff Layton , Ilya Dryomov Subject: [PATCH 5.1 293/371] ceph: fix end offset in truncate_inode_pages_range call Date: Wed, 24 Jul 2019 21:20:45 +0200 Message-Id: <20190724191746.403605494@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luis Henriques commit d31d07b97a5e76f41e00eb81dcca740e84aa7782 upstream. Commit e450f4d1a5d6 ("ceph: pass inclusive lend parameter to filemap_write_and_wait_range()") fixed the end offset parameter used to call filemap_write_and_wait_range and invalidate_inode_pages2_range. Unfortunately it missed truncate_inode_pages_range, introducing a regression that is easily detected by xfstest generic/130. The problem is that when doing direct IO it is possible that an extra page is truncated from the page cache when the end offset is page aligned. This can cause data loss if that page hasn't been sync'ed to the OSDs. While there, change code to use PAGE_ALIGN macro instead. Cc: stable@vger.kernel.org Fixes: e450f4d1a5d6 ("ceph: pass inclusive lend parameter to filemap_write_and_wait_range()") Signed-off-by: Luis Henriques Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1006,7 +1006,7 @@ ceph_direct_read_write(struct kiocb *ioc * may block. */ truncate_inode_pages_range(inode->i_mapping, pos, - (pos+len) | (PAGE_SIZE - 1)); + PAGE_ALIGN(pos + len) - 1); req->r_mtime = mtime; }