linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: rolandd@cisco.com
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] uverbs: kill last remaining modular get_empty_filp user
Date: Mon, 25 Feb 2008 20:10:43 +0100	[thread overview]
Message-ID: <20080225191043.GA32342@lst.de> (raw)

uvers should be using the proper alloc_file helper instead of an
open-coded get_empty_filp.  In fact this was the last modular user
so we can kill the export aswell and force people to use the proper
interface.

Also remove the useless setting of .owner and the fops_get because all
this is not required for file_operations instances in the same module
as the underlying filesystem.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/drivers/infiniband/core/uverbs_main.c
===================================================================
--- linux-2.6.orig/drivers/infiniband/core/uverbs_main.c	2008-02-25 20:05:12.000000000 +0100
+++ linux-2.6/drivers/infiniband/core/uverbs_main.c	2008-02-25 20:05:46.000000000 +0100
@@ -372,7 +372,6 @@ static int ib_uverbs_event_close(struct 
 }
 
 static const struct file_operations uverbs_event_fops = {
-	.owner	 = THIS_MODULE,
 	.read 	 = ib_uverbs_event_read,
 	.poll    = ib_uverbs_event_poll,
 	.release = ib_uverbs_event_close,
@@ -516,26 +515,21 @@ struct file *ib_uverbs_alloc_event_file(
 		goto err;
 	}
 
-	filp = get_empty_filp();
+	/*
+	 * fops_get() can't fail here, because we're coming from a
+	 * system call on a uverbs file, which will already have a
+	 * module reference.
+	 */
+	filp = alloc_file(uverbs_event_mnt, uverbs_event_mnt->mnt_root,
+			  FMODE_READ, &uverbs_event_fops);
 	if (!filp) {
 		ret = -ENFILE;
 		goto err_fd;
 	}
 
+	filp->private_data = ev_file;
 	ev_file->file      = filp;
 
-	/*
-	 * fops_get() can't fail here, because we're coming from a
-	 * system call on a uverbs file, which will already have a
-	 * module reference.
-	 */
-	filp->f_op 	   = fops_get(&uverbs_event_fops);
-	filp->f_path.mnt 	   = mntget(uverbs_event_mnt);
-	filp->f_path.dentry 	   = dget(uverbs_event_mnt->mnt_root);
-	filp->f_mapping    = filp->f_path.dentry->d_inode->i_mapping;
-	filp->f_flags      = O_RDONLY;
-	filp->f_mode       = FMODE_READ;
-	filp->private_data = ev_file;
 
 	return filp;
 
Index: linux-2.6/fs/file_table.c
===================================================================
--- linux-2.6.orig/fs/file_table.c	2008-02-25 20:05:12.000000000 +0100
+++ linux-2.6/fs/file_table.c	2008-02-25 20:05:46.000000000 +0100
@@ -80,9 +80,13 @@ int proc_nr_files(ctl_table *table, int 
 }
 #endif
 
-/* Find an unused file structure and return a pointer to it.
+/*
+ * Find an unused file structure and return a pointer to it.
  * Returns NULL, if there are no more free file structures or
  * we run out of memory.
+ *
+ * Note that this is an internal helper.  Please use alloc_file
+ * or anon_inode_getfd instead.
  */
 struct file *get_empty_filp(void)
 {
@@ -135,8 +139,6 @@ fail:
 	return NULL;
 }
 
-EXPORT_SYMBOL(get_empty_filp);
-
 /**
  * alloc_file - allocate and initialize a 'struct file'
  * @mnt: the vfsmount on which the file will reside

             reply	other threads:[~2008-02-25 19:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 19:10 Christoph Hellwig [this message]
2008-02-27 19:01 ` [PATCH] uverbs: kill last remaining modular get_empty_filp user Roland Dreier
2008-02-27 19:16 ` [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd() Roland Dreier
2008-02-27 19:18   ` [PATCH 2/2] IB/uverbs: Use anonymous inodes instead of private filesystem Roland Dreier
2008-02-27 19:20   ` [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd() Avi Kivity
2008-02-27 19:41   ` Davide Libenzi
2008-02-27 20:14     ` Roland Dreier
2008-02-27 20:30       ` Davide Libenzi
2008-02-27 21:05         ` Roland Dreier
2008-02-27 23:42           ` Roland Dreier
2008-02-28  7:52             ` Avi Kivity
2008-02-28 20:04             ` Davide Libenzi
2008-02-28 20:24               ` Roland Dreier
2008-02-28 20:52                 ` Davide Libenzi
2008-03-05  9:32                   ` Avi Kivity
2008-03-06 15:14             ` Christoph Hellwig
2008-03-09  2:45               ` Roland Dreier
2008-03-17 10:40                 ` Christoph Hellwig
2008-03-17 10:48                   ` Avi Kivity
2008-03-09  2:46               ` Roland Dreier
2008-03-06 15:14   ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080225191043.GA32342@lst.de \
    --to=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=rolandd@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).