Mixed use of MOD_INC_USE_COUNT and SET_MODULE_OWNER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello, all:

  I've been looking over the use of SET_MODULE_OWNER to better
understand how its operation differs from the old style of
MOD_INC_USE_COUNT / MOD_DEC_USE_COUNT.  I was under the impression
that use of the newer method was mutually exclusive of the old
method.  But, having looked over a number of modules, I see
that many combine use of the two.

  For example, loop.c.  While it does not use the SET_MODULE_OWNER
macro, it has defined owner in the lo_fops structure:

	static struct block_device_operations lo_fops = {
		owner:		THIS_MODULE,
		...

  All is well so far.  However, in methods such as loop_set_fd
and lo_open, use is made of MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT.
What leads me to believe this should not be happening is the
result of making use of the module.  A simple:

	losetup /dev/loop0 /some/diskimg
	losetup /dev/loop1 /some/other/diskimg
	mount /dev/loop0 /mnt/zero
	mount /dev/loop1 /mnt/one

results in a module 'in-use' count of 6.  Granted, umount/losetup -d
does leave the module in a zero-use state but the use count
just doesn't seem right to me.  It seems as if the mount of the
loop device is being counted twice in both cases -- once manually
in the module and once by having set the owner to THIS_MODULE.
Perhaps my understanding of how it should work is just wrong.

  Compiling the module using just the "owner" provided in lo_fops
or even explicitly using SET_MODULE_OWNER(&lo_fops); in loop_init()
seems to produce no harmful effect and produces what I think to be
a true in-use count.

  The bulk of the modules I've looked at (especially the 3cxxx
network drivers which are usually really clean) do not mix use of
old and new methods, but many drivers do so I was left a bit confused.

  If anyone can clarify how to properly use SET_MODULE_OWNER, I'd
certainly appreciate it.  Thanks much.

	Mike

--
Michael Janicki
Key: http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0x9D6FAE1A
Fingerprint: A153 DFC7 8B49 7E97 67B2  3DCE DA3F 3CC5 9D6F AE1A


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux