From patchwork Fri May 6 19:30:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enke Chen X-Patchwork-Id: 9035991 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E8086BF29F for ; Fri, 6 May 2016 19:40:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB7722039D for ; Fri, 6 May 2016 19:40:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98FD42035D for ; Fri, 6 May 2016 19:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758166AbcEFTkw (ORCPT ); Fri, 6 May 2016 15:40:52 -0400 Received: from rcdn-iport-2.cisco.com ([173.37.86.73]:52239 "EHLO rcdn-iport-2.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758144AbcEFTkv (ORCPT ); Fri, 6 May 2016 15:40:51 -0400 X-Greylist: delayed 588 seconds by postgrey-1.27 at vger.kernel.org; Fri, 06 May 2016 15:40:51 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3495; q=dns/txt; s=iport; t=1462563651; x=1463773251; h=subject:references:to:cc:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=aSUQlYmkHqxZkl+wle0wspSEnOXGzyhBnyCSvUoN2YQ=; b=BC9nUSQdUyx4Sno+UojUT5JMS6EzmmXqNFXJ1iskUOp3y2Mxf1vMwlbO oq9fguxBuNFyg3Yi9F+GXHnuEpfAPrUJABxQxrPCVVZT+ro/L04xst0aO BONUk0beyWY0bv6tumyAVLHnbEg4rWpv8kgF6dZbhies0ti5SScZ7ycB5 g=; X-IronPort-AV: E=Sophos;i="5.24,587,1454976000"; d="scan'208";a="104525511" Received: from alln-core-1.cisco.com ([173.36.13.131]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 May 2016 19:31:01 +0000 Received: from [10.154.162.58] ([10.154.162.58]) by alln-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id u46JV0GU022911; Fri, 6 May 2016 19:31:01 GMT Subject: [PATCH] FUSE: implement the check_flags operation References: <4f88283d-8a62-98b6-da63-2e6e49542fdd@cisco.com> To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, Enke Chen From: Enke Chen X-Forwarded-Message-Id: <4f88283d-8a62-98b6-da63-2e6e49542fdd@cisco.com> Message-ID: Date: Fri, 6 May 2016 12:30:59 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <4f88283d-8a62-98b6-da63-2e6e49542fdd@cisco.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-16.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implement the "check_flags" operation that passes the flag setting by fcntl() and ioctl(fd, FIONBIO, &on) to fuse-based applications. This patch depends on the following: [PATCH] VFS: pass the flag setting by fcntl() to vfs Signed-off-by: Enke Chen Version: 4.6.0_rc6_next_20160505 fs/fuse/file.c | 43 +++++++++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_i.h | 3 +++ include/uapi/linux/fuse.h | 10 ++++++++++ 3 files changed, 56 insertions(+) --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" 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/fuse/file.c b/fs/fuse/file.c index 9154f86..b457a40 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3010,6 +3010,47 @@ out: return err; } +static int fuse_do_setfl(unsigned int flags, struct file *file) +{ + struct inode *inode = file_inode(file); + struct fuse_conn *fc = get_fuse_conn(inode); + struct fuse_file *ff = file->private_data; + struct fuse_setfl_in inarg; + FUSE_ARGS(args); + int err; + + if (is_bad_inode(inode)) + return -EIO; + + if (fc->no_setfl) + return 0; + + inarg.fh = ff->fh; + inarg.flags = flags; + inarg.setting = 1; + args.in.h.opcode = FUSE_SETFL; + args.in.h.nodeid = get_node_id(inode); + args.in.numargs = 1; + args.in.args[0].size = sizeof(inarg); + args.in.args[0].value = &inarg; + err = fuse_simple_request(fc, &args); + if (err == -ENOSYS) { + fc->no_setfl = 1; + err = 0; + } + + return err; +} + +static int fuse_file_check_flags(unsigned int flags, struct file *file, + int setting) +{ + if (!setting) + return 0; + + return fuse_do_setfl(flags, file); +} + static const struct file_operations fuse_file_operations = { .llseek = fuse_file_llseek, .read_iter = fuse_file_read_iter, @@ -3026,6 +3067,7 @@ static const struct file_operations fuse_file_operations = { .compat_ioctl = fuse_file_compat_ioctl, .poll = fuse_file_poll, .fallocate = fuse_file_fallocate, + .check_flags = fuse_file_check_flags, }; static const struct file_operations fuse_direct_io_file_operations = { @@ -3044,6 +3086,7 @@ static const struct file_operations fuse_direct_io_file_operations = { .poll = fuse_file_poll, .fallocate = fuse_file_fallocate, /* no splice_read */ + .check_flags = fuse_file_check_flags, }; static const struct address_space_operations fuse_file_aops = { diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index eddbe02..70b4f8d 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -617,6 +617,9 @@ struct fuse_conn { /** Is lseek not implemented by fs? */ unsigned no_lseek:1; + /** Is setfl implemented by fs? */ + unsigned no_setfl:1; + /** The number of requests waiting for completion */ atomic_t num_waiting; diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 5974fae..c068650 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -105,6 +105,9 @@ * * 7.24 * - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support + * + * 7.25 + * - add FUSE_SETFL */ #ifndef _LINUX_FUSE_H @@ -362,6 +365,7 @@ enum fuse_opcode { FUSE_READDIRPLUS = 44, FUSE_RENAME2 = 45, FUSE_LSEEK = 46, + FUSE_SETFL = 47, /* CUSE specific operations */ CUSE_INIT = 4096, @@ -773,4 +777,10 @@ struct fuse_lseek_out { uint64_t offset; }; +struct fuse_setfl_in { + uint64_t fh; + uint32_t flags; + uint32_t setting; +}; + #endif /* _LINUX_FUSE_H */