Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp647815pxb; Mon, 25 Oct 2021 15:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiUAAQJsF9jkbCXws7X4jIvH9NTbuPb3Mqa6qIylguTsNTalhGiErtPCK3e10REGIk7A6i X-Received: by 2002:a17:902:b18a:b0:13e:e5f3:1b25 with SMTP id s10-20020a170902b18a00b0013ee5f31b25mr18946187plr.78.1635202091251; Mon, 25 Oct 2021 15:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635202091; cv=none; d=google.com; s=arc-20160816; b=Jj9X0CThpuNmATFKYaSIzAZX0+MxZvejD003m+FDPCNff7wj4/4zik93akc3zCTpdV 9v8gOKuI7IYpQpXMJpOKnguTNvpijJSiqoRsAXhfCYLnpZF1g6LHwF5si1458GgrusMT 7XgJe8o9Ikc8Z+VxUbvcyyMOTq0xWihBnL8bEN74oiHpMToic1LbbOWr0cjlNy9gurWB c78Qw4qNbOCUPofSpQ9AFF1eRzK3zc/9Zd9nT3PBpPRFZ7RTTXan7BkqabIXbkgU62TD +8uvpcpwo4T03vU9HTqPtVghsunER6PBmkIIbganNhhjT2IwNTKFOUX8lqG6Ju7w6uA4 4YOA== 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:subject:cc:to :from:dkim-signature; bh=mTWIN9VmQaA2B2hbWySCATxyHTiA1z4UzIgY+jDTPOc=; b=WMUCjVG5e5X462TJOxTBKPL4IOYs2y8P8y0zgmjbJJLc3DJd8if6/XVX8NHpbmG32Z gSgLllzahA/Vlj/RjJ4Ok3jpoeLaNNYg7y+VXxHX51/bTuroK8MuXXSpvdaHUrWKolbD LOLVLzKi2se3+YorGGvrgvWLc8vX4cgEoo8RppE7iBu9qqwyFhbnsz0xxWKLhmKF1j0O E8+bFM+YLyykQR69pkpEDllLqDMb5ah9MOyhTc4NfW6YBV7UYt8CCUmd16+oWPZdg4li ZDRTm0X9Uc7/9EBQegeFKs0p1APB+EuXThkHQbpKD7GaPJa/JJgT45d1F1cQ+qNbyYxN MVFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QkHU4OCz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si29000983pfh.153.2021.10.25.15.47.58; Mon, 25 Oct 2021 15:48:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=QkHU4OCz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235437AbhJYTgV (ORCPT + 99 others); Mon, 25 Oct 2021 15:36:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235355AbhJYT3o (ORCPT ); Mon, 25 Oct 2021 15:29:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 424F060FE8; Mon, 25 Oct 2021 19:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190011; bh=dZL0HkKLfPiYFXAEZO8A5y1YUcudAsryqSfPfFfRvXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QkHU4OCz24JbJnihZ4pheGo1JGwUPK9+bGXxhQWLS49l2d/QJ2bs+C00Je/lYylTk rWQ5WCfrzHq+MAwGh32O8X+Wkd2aHZzY6IzsD0M6BUHWFPxS61ERlATLUpTCna09R0 dTOrVgY/BZtjknNsjhY+RoyVNe7H2me2PPcus9ok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrick Donnelly , Jeff Layton , Xiubo Li , Ilya Dryomov Subject: [PATCH 5.4 26/58] ceph: fix handling of "meta" errors Date: Mon, 25 Oct 2021 21:14:43 +0200 Message-Id: <20211025190941.839507576@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190937.555108060@linuxfoundation.org> References: <20211025190937.555108060@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Layton commit 1bd85aa65d0e7b5e4d09240f492f37c569fdd431 upstream. Currently, we check the wb_err too early for directories, before all of the unsafe child requests have been waited on. In order to fix that we need to check the mapping->wb_err later nearer to the end of ceph_fsync. We also have an overly-complex method for tracking errors after blocklisting. The errors recorded in cleanup_session_requests go to a completely separate field in the inode, but we end up reporting them the same way we would for any other error (in fsync). There's no real benefit to tracking these errors in two different places, since the only reporting mechanism for them is in fsync, and we'd need to advance them both every time. Given that, we can just remove i_meta_err, and convert the places that used it to instead just use mapping->wb_err instead. That also fixes the original problem by ensuring that we do a check_and_advance of the wb_err at the end of the fsync op. Cc: stable@vger.kernel.org URL: https://tracker.ceph.com/issues/52864 Reported-by: Patrick Donnelly Signed-off-by: Jeff Layton Reviewed-by: Xiubo Li Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/caps.c | 12 +++--------- fs/ceph/file.c | 1 - fs/ceph/inode.c | 2 -- fs/ceph/mds_client.c | 17 +++++------------ fs/ceph/super.h | 3 --- 5 files changed, 8 insertions(+), 27 deletions(-) --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2249,7 +2249,6 @@ static int unsafe_request_wait(struct in int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync) { - struct ceph_file_info *fi = file->private_data; struct inode *inode = file->f_mapping->host; struct ceph_inode_info *ci = ceph_inode(inode); u64 flush_tid; @@ -2280,14 +2279,9 @@ int ceph_fsync(struct file *file, loff_t if (err < 0) ret = err; - if (errseq_check(&ci->i_meta_err, READ_ONCE(fi->meta_err))) { - spin_lock(&file->f_lock); - err = errseq_check_and_advance(&ci->i_meta_err, - &fi->meta_err); - spin_unlock(&file->f_lock); - if (err < 0) - ret = err; - } + err = file_check_and_advance_wb_err(file); + if (err < 0) + ret = err; out: dout("fsync %p%s result=%d\n", inode, datasync ? " datasync" : "", ret); return ret; --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -234,7 +234,6 @@ static int ceph_init_file_info(struct in fi->fmode = fmode; spin_lock_init(&fi->rw_contexts_lock); INIT_LIST_HEAD(&fi->rw_contexts); - fi->meta_err = errseq_sample(&ci->i_meta_err); fi->filp_gen = READ_ONCE(ceph_inode_to_client(inode)->filp_gen); return 0; --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -515,8 +515,6 @@ struct inode *ceph_alloc_inode(struct su ceph_fscache_inode_init(ci); - ci->i_meta_err = 0; - return &ci->vfs_inode; } --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1272,7 +1272,6 @@ static void cleanup_session_requests(str { struct ceph_mds_request *req; struct rb_node *p; - struct ceph_inode_info *ci; dout("cleanup_session_requests mds%d\n", session->s_mds); mutex_lock(&mdsc->mutex); @@ -1281,16 +1280,10 @@ static void cleanup_session_requests(str struct ceph_mds_request, r_unsafe_item); pr_warn_ratelimited(" dropping unsafe request %llu\n", req->r_tid); - if (req->r_target_inode) { - /* dropping unsafe change of inode's attributes */ - ci = ceph_inode(req->r_target_inode); - errseq_set(&ci->i_meta_err, -EIO); - } - if (req->r_unsafe_dir) { - /* dropping unsafe directory operation */ - ci = ceph_inode(req->r_unsafe_dir); - errseq_set(&ci->i_meta_err, -EIO); - } + if (req->r_target_inode) + mapping_set_error(req->r_target_inode->i_mapping, -EIO); + if (req->r_unsafe_dir) + mapping_set_error(req->r_unsafe_dir->i_mapping, -EIO); __unregister_request(mdsc, req); } /* zero r_attempts, so kick_requests() will re-send requests */ @@ -1436,7 +1429,7 @@ static int remove_session_caps_cb(struct spin_unlock(&mdsc->cap_dirty_lock); if (dirty_dropped) { - errseq_set(&ci->i_meta_err, -EIO); + mapping_set_error(inode->i_mapping, -EIO); if (ci->i_wrbuffer_ref_head == 0 && ci->i_wr_ref == 0 && --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -402,8 +402,6 @@ struct ceph_inode_info { struct fscache_cookie *fscache; u32 i_fscache_gen; #endif - errseq_t i_meta_err; - struct inode vfs_inode; /* at end */ }; @@ -712,7 +710,6 @@ struct ceph_file_info { spinlock_t rw_contexts_lock; struct list_head rw_contexts; - errseq_t meta_err; u32 filp_gen; atomic_t num_locks; };