From patchwork Mon Dec 9 09:28:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 11278723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C4311575 for ; Mon, 9 Dec 2019 09:28:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A5BC2073D for ; Mon, 9 Dec 2019 09:28:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WVjJtBb4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfLIJ2q (ORCPT ); Mon, 9 Dec 2019 04:28:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58450 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727144AbfLIJ2q (ORCPT ); Mon, 9 Dec 2019 04:28:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575883724; 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; bh=3pTBDLl0BWbJPd5nPsQpBfReTw+s4WliLhpqo/bH5Mo=; b=WVjJtBb4IoWzeGuhXC5GpAt5WUQBHhdxbnFK2mOOFV869ON0SwuKH/4+HpRPiDrrlHeTwK uL70Bn/gmJhuhbaMYvwh78jM0jf+rZKYrO59CYgIqETNiO01fUhTqa14rnNYTH7otxufgl YkxmA4n+BqTXcWNMtZyLUXxGa2lRjvE= 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-326-L4OqxVT0NNigwAy_qzq_NQ-1; Mon, 09 Dec 2019 04:28:43 -0500 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 0EC1C1005512; Mon, 9 Dec 2019 09:28:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-181.pek2.redhat.com [10.72.12.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24BF85C545; Mon, 9 Dec 2019 09:28:35 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: sage@redhat.com, idryomov@gmail.com, zyan@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH] ceph: clean the dirty page when session is closed or rejected Date: Mon, 9 Dec 2019 04:28:30 -0500 Message-Id: <20191209092830.22157-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: L4OqxVT0NNigwAy_qzq_NQ-1 X-Mimecast-Spam-Score: 0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li Try to queue writeback and invalidate the dirty pages when sessions are closed, rejected or reconnect denied. Signed-off-by: Xiubo Li --- fs/ceph/mds_client.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index be1ac9f8e0e6..68f3b5ed6ac8 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1385,9 +1385,11 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap, { struct ceph_fs_client *fsc = (struct ceph_fs_client *)arg; struct ceph_inode_info *ci = ceph_inode(inode); + struct ceph_mds_session *session = cap->session; LIST_HEAD(to_remove); bool dirty_dropped = false; bool invalidate = false; + bool writeback = false; dout("removing cap %p, ci is %p, inode is %p\n", cap, ci, &ci->vfs_inode); @@ -1398,12 +1400,21 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap, if (!ci->i_auth_cap) { struct ceph_cap_flush *cf; struct ceph_mds_client *mdsc = fsc->mdsc; + int s_state = session->s_state; if (READ_ONCE(fsc->mount_state) == CEPH_MOUNT_SHUTDOWN) { if (inode->i_data.nrpages > 0) invalidate = true; if (ci->i_wrbuffer_ref > 0) mapping_set_error(&inode->i_data, -EIO); + } else if (s_state == CEPH_MDS_SESSION_CLOSED || + s_state == CEPH_MDS_SESSION_REJECTED) { + /* reconnect denied or rejected */ + if (!__ceph_is_any_real_caps(ci) && + inode->i_data.nrpages > 0) + invalidate = true; + if (ci->i_wrbuffer_ref > 0) + writeback = true; } while (!list_empty(&ci->i_cap_flush_list)) { @@ -1472,6 +1483,8 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap, } wake_up_all(&ci->i_cap_wq); + if (writeback) + ceph_queue_writeback(inode); if (invalidate) ceph_queue_invalidate(inode); if (dirty_dropped)