All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>,
	Kees Cook <keescook@chromium.org>,
	Tony Luck <tony.luck@intel.com>
Cc: Geliang Tang <geliangtang@163.com>, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] pstore: drop file opened reference count
Date: Sat,  7 Nov 2015 12:43:49 +0800	[thread overview]
Message-ID: <4df0455fbe40f22f36ad5d3752c1d67ff4ec0b44.1446869434.git.geliangtang@163.com> (raw)
In-Reply-To: <cover.1446869434.git.geliangtang@163.com>
In-Reply-To: <c203e0cfee351d6f97c6a1a42c3e25b4be339f93.1446869434.git.geliangtang@163.com>

In my recent commit, I added '.owner = THIS_MODULE' in both
pstore_fs_type and pstore_file_operations to increase a reference count
when pstore filesystem is mounted and pstore file is opened.[1]

But, it's repetitive. There is no need to increase the opened reference
count. We only need to increase the mounted reference count. When a file
is opened, the filesystem can't be unmounted. Hence the pstore module
can't be unloaded either.

So I drop the opened reference count in this patch.

[1] https://lkml.org/lkml/2015/10/20/84

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
Here is the reference count test:

$ sudo /sbin/insmod lib/zlib_deflate/zlib_deflate.ko
$ sudo /sbin/insmod fs/pstore/pstore.ko
$ lsmod
Module                  Size  Used by
pstore                 13301  0
zlib_deflate           20156  1 pstore

$ sudo mount -t pstore pstore /sys/fs/pstore
$ lsmod
Module                  Size  Used by
pstore                 13301  1
zlib_deflate           20156  1 pstore

$ sudo /sbin/insmod lib/reed_solomon/reed_solomon.ko
$ sudo /sbin/insmod fs/pstore/ramoops.ko mem_address=0x80000000 mem_size=0x40000 ecc=1
$ lsmod
Module                  Size  Used by
ramoops                11156  0
reed_solomon            5878  1 ramoops
pstore                 13301  2 ramoops
zlib_deflate           20156  1 pstore

$ sudo rmmod ramoops
$ lsmod
Module                  Size  Used by
reed_solomon            5878  0
pstore                 13301  1
zlib_deflate           20156  1 pstore

$ tail -f /sys/fs/pstore/console-ramoops-0 &
[1] 4479
$ lsmod
Module                  Size  Used by
reed_solomon            5878  0
pstore                 13301  1
zlib_deflate           20156  1 pstore

$ sudo umount /sys/fs/pstore
umount: /sys/fs/pstore: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)

$ kill -9 4479
[1]+  Killed                  tail -f /sys/fs/pstore/console-ramoops-0
$ lsmod
Module                  Size  Used by
reed_solomon            5878  0
pstore                 13301  1
zlib_deflate           20156  1 pstore

$ sudo umount /sys/fs/pstore
$ lsmod
Module                  Size  Used by
reed_solomon            5878  0
pstore                 13301  0
zlib_deflate           20156  1 pstore

$ sudo rmmod pstore
$ lsmod
Module                  Size  Used by
reed_solomon            5878  0
zlib_deflate           20156  0
---
 fs/pstore/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index d8c439d..ac6c78fe 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -178,7 +178,6 @@ static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence)
 }
 
 static const struct file_operations pstore_file_operations = {
-	.owner		= THIS_MODULE,
 	.open		= pstore_file_open,
 	.read		= pstore_file_read,
 	.llseek		= pstore_file_llseek,
-- 
2.5.0



  reply	other threads:[~2015-11-07  4:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-07  4:43 [PATCH v2 0/3] pstore: resend three patches Geliang Tang
2015-11-07  4:43 ` Geliang Tang
2015-11-07  4:43 ` [PATCH v2 1/3] pstore: check PSTORE_FLAGS_FRAGILE in pstore_unregister Geliang Tang
2015-11-07  4:43   ` [PATCH v2 2/3] efi-pstore: implement efivars_pstore_exit() Geliang Tang
2015-11-07  4:43     ` Geliang Tang [this message]
2015-11-11 16:59     ` Matt Fleming
2015-11-11 16:59       ` Matt Fleming
2015-11-11 23:08       ` Kees Cook
2015-11-11 23:23         ` Luck, Tony
2015-11-11 23:23           ` Luck, Tony
2015-11-11 23:24           ` Kees Cook
2015-11-11 23:24             ` Kees Cook
2016-06-02  7:26             ` Geliang Tang, Kees Cook
2016-06-02  7:26               ` Geliang Tang, Kees Cook
2016-06-02 18:26               ` Kees Cook
2016-06-02 18:26                 ` Kees Cook
2015-11-12 12:22           ` Matt Fleming
2016-06-02 18:17   ` [PATCH v2 1/3] pstore: check PSTORE_FLAGS_FRAGILE in pstore_unregister Kees Cook

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=4df0455fbe40f22f36ad5d3752c1d67ff4ec0b44.1446869434.git.geliangtang@163.com \
    --to=geliangtang@163.com \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.