From patchwork Mon Dec 11 06:04:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10104275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B8C6760235 for ; Mon, 11 Dec 2017 06:05:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F66293F8 for ; Mon, 11 Dec 2017 06:05:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DEBE2940B; Mon, 11 Dec 2017 06:05:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4502C293F8 for ; Mon, 11 Dec 2017 06:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750759AbdLKGE1 (ORCPT ); Mon, 11 Dec 2017 01:04:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:46355 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbdLKGEZ (ORCPT ); Mon, 11 Dec 2017 01:04:25 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D89EDAAC7; Mon, 11 Dec 2017 06:04:23 +0000 (UTC) From: NeilBrown To: Linus Torvalds , Al Viro Date: Mon, 11 Dec 2017 17:04:05 +1100 Subject: [PATCH 1/4] fs/notify: fdinfo can report unsupported file handles. Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, Amir Goldstein , lkml , Lennart Poettering Message-ID: <151297224512.7818.18333908109878259066.stgit@noble> In-Reply-To: <151297214390.7818.7216826079527521005.stgit@noble> References: <151297214390.7818.7216826079527521005.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a filesystem does not set sb->s_export_op, then it does not support filehandles and export_fs_encode_fh() and exportfs_encode_inode_fh() should not be called. They will use export_encode_fh() is which is a default that uses inode number generation number, but in general they may not be stable. So change exportfs_encode_inode_fh() to return FILEID_INVALID if called on an unsupported Filesystem. Currently only notify/fdinfo can do that. Also remove the WARNing from fdinfo when exportfs_encode_inode_fh() returns FILEID_INVALID, as that is no an erroneous condition. Signed-off-by: NeilBrown --- fs/exportfs/expfs.c | 4 +++- fs/notify/fdinfo.c | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 329a5d103846..f5b27dd843a1 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -385,7 +385,9 @@ int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid, { const struct export_operations *nop = inode->i_sb->s_export_op; - if (nop && nop->encode_fh) + if (nop) + return FILEID_INVALID; + if (nop->encode_fh) return nop->encode_fh(inode, fid->raw, max_len, parent); return export_encode_fh(inode, fid, max_len, parent); diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c index d478629c728b..d1135ed61229 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c @@ -50,10 +50,8 @@ static void show_mark_fhandle(struct seq_file *m, struct inode *inode) size = f.handle.handle_bytes >> 2; ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); - if ((ret == FILEID_INVALID) || (ret < 0)) { - WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); + if ((ret == FILEID_INVALID) || (ret < 0)) return; - } f.handle.handle_type = ret; f.handle.handle_bytes = size * sizeof(u32);