Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3278473pxf; Mon, 22 Mar 2021 02:28:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhfnZYfHAc9FW2Jtip4Dt9s7APAYRG6spe1bp2VKMmaamh/nqTJlKuWBrRzSUJrPhlT5dV X-Received: by 2002:a17:907:720a:: with SMTP id dr10mr10543517ejc.375.1616405312645; Mon, 22 Mar 2021 02:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616405312; cv=none; d=google.com; s=arc-20160816; b=k9+Ml2NOo0LP8xJD1S+UM8PFSPVzhQdIzNnU0owRZl+NnGq0ix1V9Rm7zkoCk4hzoq HxU7VY0+mAq+Mv06Z+Ogw2mD7sVSjVtRIxIGDBhxeoDMDhp8zHOa1Sl2fKuDl7eA1+5I OQElHTOBmRuUmxqnmYFbQrZdqLncy1gp3/xsre5MyUIvFKYP6hGe4ql0Sk1Eh5oBEWYK NnQIUpbBVeYl2PViQancfSP4/Ud3jJFfTvFLoChMLrXC+gCyPkMX5MqlzwAqviZIaThT YJ5FNCF9r3xYBQQa7qwZWQfxv0kpCW2fYivYFOcN138C5RK9sSrFH6ZlELIHwQO2j54w 3xvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j6MQYdgV4+wrTyHhu2dfzLl8kL+VrmbYPGbkoPs/QS8=; b=QY75378FMhfa5GJN8rMkYrlzIaH9FYi0fBmtgLUwGO3KMUzDg8VZAGBm0DD07ZFvcF u3NXz/uRA42mP1uydsQEGMN/qhGkh7A4lOvd5pLubQaTKj9EeO1C3H0D4mlVxMM/D1B6 QNgLUYKIdL+xscOZW6TLO7ukrS4nJcmxjaQ3h+JGRcjfF6Dw+w/GUUPYVCvzdyFo7OXC MjvdjRplfXXfKTvcbZKuL0HOhksosSuFI2tNeqbujns7QV7rweEnue+bZPF/HrTlfZaq 7YFjzAFsQ5gqB0SJ+DoLWTEx+juyEUKIoSe9Pxrq6vK2ZZhITd+RbsRMiLVTL592wPIF iBDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=diQyqW5u; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si11379625ejv.268.2021.03.22.02.28.10; Mon, 22 Mar 2021 02:28:32 -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=@chromium.org header.s=google header.b=diQyqW5u; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbhCVJ1N (ORCPT + 99 others); Mon, 22 Mar 2021 05:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbhCVJ0m (ORCPT ); Mon, 22 Mar 2021 05:26:42 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B14C061574 for ; Mon, 22 Mar 2021 02:26:41 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so8167633pjg.5 for ; Mon, 22 Mar 2021 02:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=j6MQYdgV4+wrTyHhu2dfzLl8kL+VrmbYPGbkoPs/QS8=; b=diQyqW5ujUZUblbt4D/7jo9LBNUMguG/HQqovdtOTW5/q+hkldXGSyg+FkHbv01hyy pUndIPR3X/gJ3G/x8gM0LA/D2ePJo2eb3QW6+pkYkNCtdfxqQX7KuGb2YNsSJqf5x6sv 21L0K+LjYZvr9lCqfiLvM0CYvifCgk+G4PIXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=j6MQYdgV4+wrTyHhu2dfzLl8kL+VrmbYPGbkoPs/QS8=; b=fEX0WLxvdEYPGrr34YinUy3Ziz8lXOOLPS0MJYI94z6aBRSlzWsg9xytHTvJincH3p urzcJaqfW/8Eoc4TyMrqY6Eum6BZrHaGIjGOcTIrXB4xxL6cz4AG5ISYrI9q3d7o/4vX icfxoHblak8i7bwP+sQRl2+HTInOKaww3uIdd8sb2y/ZAZPvy4/CeTfp2o4DuiNmrr3g qUtwIiQw6Wa5oGjc0gCAPabPg2xdC4RyPS/EFtjrgc5DSn90YQwB+pYk7r7kZbMbLin1 wh+OaDuXb7zmTo+8WZKJkLp/xGc75/AZuEhzShjr+c7ogCqMzCo0EEd59l13FNYkFS+w ymhg== X-Gm-Message-State: AOAM532o5kdky/0/PZTupWBtDLInvrPXZoJivALxilt6Lgjk6TPabGn0 OlXZ2V8pTB3nqd+3JOG6WaDHkQ== X-Received: by 2002:a17:90a:5898:: with SMTP id j24mr12508922pji.103.1616405200556; Mon, 22 Mar 2021 02:26:40 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:b1b5:270:5df6:6d6e]) by smtp.gmail.com with ESMTPSA id v25sm13197661pfn.51.2021.03.22.02.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 02:26:40 -0700 (PDT) Date: Mon, 22 Mar 2021 18:26:33 +0900 From: Sergey Senozhatsky To: Al Viro Cc: Namjae Jeon , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-cifsd-devel@lists.sourceforge.net, smfrench@gmail.com, senozhatsky@chromium.org, hyc.lee@gmail.com, hch@lst.de, hch@infradead.org, ronniesahlberg@gmail.com, aurelien.aptel@gmail.com, aaptel@suse.com, sandeen@sandeen.net, dan.carpenter@oracle.com, colin.king@canonical.com, rdunlap@infradead.org, Sergey Senozhatsky , Steve French Subject: Re: [PATCH 3/5] cifsd: add file operations Message-ID: References: <20210322051344.1706-1-namjae.jeon@samsung.com> <20210322051344.1706-4-namjae.jeon@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (21/03/22 07:02), Al Viro wrote: > On Mon, Mar 22, 2021 at 02:13:42PM +0900, Namjae Jeon wrote: > > +static struct ksmbd_file *__ksmbd_lookup_fd(struct ksmbd_file_table *ft, > > + unsigned int id) > > +{ > > + bool unclaimed = true; > > + struct ksmbd_file *fp; > > + > > + read_lock(&ft->lock); > > + fp = idr_find(ft->idr, id); > > + if (fp) > > + fp = ksmbd_fp_get(fp); > > + > > + if (fp && fp->f_ci) { > > + read_lock(&fp->f_ci->m_lock); > > + unclaimed = list_empty(&fp->node); > > + read_unlock(&fp->f_ci->m_lock); > > + } > > + read_unlock(&ft->lock); > > + > > + if (fp && unclaimed) { > > + atomic_dec(&fp->refcount); > > + return NULL; > > + } > > Can that atomic_dec() end up dropping the last remaining reference? Yes, I think it should increment refcount only for "claimed" fp.