Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12012
b: refs/heads/master
c: 4c48b0d
h: refs/heads/master
v: v3
  • Loading branch information
Steve French committed Jul 15, 2005
1 parent 891e517 commit dc3f99c
Show file tree
Hide file tree
Showing 103 changed files with 1,024 additions and 1,733 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f4cfd69cf349dd27e00d5cf804b57aee04e059c2
refs/heads/master: 4c48b0d3d1c7ff9f13134b30e41c6e81a92027bf
77 changes: 45 additions & 32 deletions trunk/Documentation/filesystems/inotify.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
inotify
a powerful yet simple file change notification system
inotify
a powerful yet simple file change notification system



Document started 15 Mar 2005 by Robert Love <rml@novell.com>


(i) User Interface

Inotify is controlled by a set of three sys calls
Inotify is controlled by a set of three system calls and normal file I/O on a
returned file descriptor.

First step in using inotify is to initialise an inotify instance
First step in using inotify is to initialise an inotify instance:

int fd = inotify_init ();

Each instance is associated with a unique, ordered queue.

Change events are managed by "watches". A watch is an (object,mask) pair where
the object is a file or directory and the mask is a bit mask of one or more
inotify events that the application wishes to receive. See <linux/inotify.h>
Expand All @@ -22,51 +26,60 @@ Watches are added via a path to the file.

Watches on a directory will return events on any files inside of the directory.

Adding a watch is simple,
Adding a watch is simple:

int wd = inotify_add_watch (fd, path, mask);

You can add a large number of files via something like

for each file to watch {
int wd = inotify_add_watch (fd, file, mask);
}
Where "fd" is the return value from inotify_init(), path is the path to the
object to watch, and mask is the watch mask (see <linux/inotify.h>).

You can update an existing watch in the same manner, by passing in a new mask.

An existing watch is removed via the INOTIFY_IGNORE ioctl, for example
An existing watch is removed via

inotify_rm_watch (fd, wd);
int ret = inotify_rm_watch (fd, wd);

Events are provided in the form of an inotify_event structure that is read(2)
from a inotify instance fd. The filename is of dynamic length and follows the
struct. It is of size len. The filename is padded with null bytes to ensure
proper alignment. This padding is reflected in len.
from a given inotify instance. The filename is of dynamic length and follows
the struct. It is of size len. The filename is padded with null bytes to
ensure proper alignment. This padding is reflected in len.

You can slurp multiple events by passing a large buffer, for example

size_t len = read (fd, buf, BUF_LEN);

Will return as many events as are available and fit in BUF_LEN.
Where "buf" is a pointer to an array of "inotify_event" structures at least
BUF_LEN bytes in size. The above example will return as many events as are
available and fit in BUF_LEN.

each inotify instance fd is also select()- and poll()-able.
Each inotify instance fd is also select()- and poll()-able.

You can find the size of the current event queue via the FIONREAD ioctl.
You can find the size of the current event queue via the standard FIONREAD
ioctl on the fd returned by inotify_init().

All watches are destroyed and cleaned up on close.


(ii) Internal Kernel Implementation
(ii)

Prototypes:

int inotify_init (void);
int inotify_add_watch (int fd, const char *path, __u32 mask);
int inotify_rm_watch (int fd, __u32 mask);


Each open inotify instance is associated with an inotify_device structure.
(iii) Internal Kernel Implementation

Each inotify instance is associated with an inotify_device structure.

Each watch is associated with an inotify_watch structure. Watches are chained
off of each associated device and each associated inode.

See fs/inotify.c for the locking and lifetime rules.


(iii) Rationale
(iv) Rationale

Q: What is the design decision behind not tying the watch to the open fd of
the watched object?
Expand All @@ -75,9 +88,9 @@ A: Watches are associated with an open inotify device, not an open file.
This solves the primary problem with dnotify: keeping the file open pins
the file and thus, worse, pins the mount. Dnotify is therefore infeasible
for use on a desktop system with removable media as the media cannot be
unmounted.
unmounted. Watching a file should not require that it be open.

Q: What is the design decision behind using an-fd-per-device as opposed to
Q: What is the design decision behind using an-fd-per-instance as opposed to
an fd-per-watch?

A: An fd-per-watch quickly consumes more file descriptors than are allowed,
Expand All @@ -86,8 +99,8 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
can use epoll, but requiring both is a silly and extraneous requirement.
A watch consumes less memory than an open file, separating the number
spaces is thus sensible. The current design is what user-space developers
want: Users initialize inotify, once, and add n watches, requiring but one fd
and no twiddling with fd limits. Initializing an inotify instance two
want: Users initialize inotify, once, and add n watches, requiring but one
fd and no twiddling with fd limits. Initializing an inotify instance two
thousand times is silly. If we can implement user-space's preferences
cleanly--and we can, the idr layer makes stuff like this trivial--then we
should.
Expand All @@ -111,9 +124,6 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
example, love it. Trust me, I asked. It is not a surprise: Who'd want
to manage and block on 1000 fd's via select?

- You'd have to manage the fd's, as an example: Call close() when you
received a delete event.

- No way to get out of band data.

- 1024 is still too low. ;-)
Expand All @@ -122,6 +132,11 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
scales to 1000s of directories, juggling 1000s of fd's just does not seem
the right interface. It is too heavy.

Additionally, it _is_ possible to more than one instance and
juggle more than one queue and thus more than one associated fd. There
need not be a one-fd-per-process mapping; it is one-fd-per-queue and a
process can easily want more than one queue.

Q: Why the system call approach?

A: The poor user-space interface is the second biggest problem with dnotify.
Expand All @@ -131,8 +146,6 @@ A: The poor user-space interface is the second biggest problem with dnotify.
Obtaining the fd and managing the watches could have been done either via a
device file or a family of new system calls. We decided to implement a
family of system calls because that is the preffered approach for new kernel
features and it means our user interface requirements.

Additionally, it _is_ possible to more than one instance and
juggle more than one queue and thus more than one associated fd.
interfaces. The only real difference was whether we wanted to use open(2)
and ioctl(2) or a couple of new system calls. System calls beat ioctls.

12 changes: 12 additions & 0 deletions trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@ L: linux-input@atrey.karlin.mff.cuni.cz
L: linux-joystick@atrey.karlin.mff.cuni.cz
S: Maintained

INOTIFY
P: John McCutchan and Robert Love
M: ttb@tentacle.dhs.org and rml@novell.com
L: linux-kernel@vger.kernel.org
S: Maintained

INTEL 810/815 FRAMEBUFFER DRIVER
P: Antonino Daplas
M: adaplas@pol.net
Expand Down Expand Up @@ -2420,6 +2426,12 @@ L: linux-usb-users@lists.sourceforge.net
L: linux-usb-devel@lists.sourceforge.net
S: Maintained

USB OPTION-CARD DRIVER
P: Matthias Urlichs
M: smurf@smurf.noris.de
L: linux-usb-devel@lists.sourceforge.net
S: Maintained

USB OV511 DRIVER
P: Mark McClelland
M: mmcclell@bigfoot.com
Expand Down
7 changes: 4 additions & 3 deletions trunk/arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* The present bitmask indicates that the CPU is physically present.
* The online bitmask indicates that the CPU is up and running.
*/
cpumask_t cpu_present_mask;
cpumask_t cpu_possible_map;
cpumask_t cpu_online_map;

/*
Expand Down Expand Up @@ -235,7 +235,8 @@ void __init smp_prepare_boot_cpu(void)
{
unsigned int cpu = smp_processor_id();

cpu_set(cpu, cpu_present_mask);
cpu_set(cpu, cpu_possible_map);
cpu_set(cpu, cpu_present_map);
cpu_set(cpu, cpu_online_map);
}

Expand Down Expand Up @@ -355,7 +356,7 @@ void show_ipi_list(struct seq_file *p)

seq_puts(p, "IPI:");

for_each_online_cpu(cpu)
for_each_present_cpu(cpu)
seq_printf(p, " %10lu", per_cpu(ipi_data, cpu).ipi_count);

seq_putc(p, '\n');
Expand Down
8 changes: 5 additions & 3 deletions trunk/arch/arm/mach-integrator/platsmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
max_cpus = ncores;

/*
* Initialise the present mask - this tells us which CPUs should
* be present.
* Initialise the possible/present maps.
* cpu_possible_map describes the set of CPUs which may be present
* cpu_present_map describes the set of CPUs populated
*/
for (i = 0; i < max_cpus; i++) {
cpu_set(i, cpu_present_mask);
cpu_set(i, cpu_possible_map);
cpu_set(i, cpu_present_map);
}

/*
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/arm/mach-omap1/leds-h2p2-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/init.h>
#include <linux/kernel_stat.h>
#include <linux/sched.h>
#include <linux/version.h>

#include <asm/io.h>
#include <asm/hardware.h>
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/arm/nwfpe/fpmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "fpa11.h"

#include <linux/module.h>
#include <linux/version.h>
#include <linux/config.h>

/* XXX */
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/arm/plat-omap/ocpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <linux/config.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/i386/mach-visws/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "piix4.h"

void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);

void machine_restart(char * __unused)
{
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/i386/mach-voyager/voyager_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Power off function, if any
*/
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);

int voyager_level = 0;

Expand Down
6 changes: 6 additions & 0 deletions trunk/arch/i386/mach-voyager/voyager_smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* the voyager hal to provide the functionality
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/kernel_stat.h>
#include <linux/delay.h>
Expand Down Expand Up @@ -40,6 +41,7 @@ static unsigned long cpu_irq_affinity[NR_CPUS] __cacheline_aligned = { [0 ... NR
/* per CPU data structure (for /proc/cpuinfo et al), visible externally
* indexed physically */
struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
EXPORT_SYMBOL(cpu_data);

/* physical ID of the CPU used to boot the system */
unsigned char boot_cpu_id;
Expand Down Expand Up @@ -72,6 +74,7 @@ static volatile unsigned long smp_invalidate_needed;
/* Bitmask of currently online CPUs - used by setup.c for
/proc/cpuinfo, visible externally but still physical */
cpumask_t cpu_online_map = CPU_MASK_NONE;
EXPORT_SYMBOL(cpu_online_map);

/* Bitmask of CPUs present in the system - exported by i386_syms.c, used
* by scheduler but indexed physically */
Expand Down Expand Up @@ -238,6 +241,7 @@ static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
/* This is for the new dynamic CPU boot code */
cpumask_t cpu_callin_map = CPU_MASK_NONE;
cpumask_t cpu_callout_map = CPU_MASK_NONE;
EXPORT_SYMBOL(cpu_callout_map);

/* The per processor IRQ masks (these are usually kept in sync) */
static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned;
Expand Down Expand Up @@ -978,6 +982,7 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)

preempt_enable();
}
EXPORT_SYMBOL(flush_tlb_page);

/* enable the requested IRQs */
static void
Expand Down Expand Up @@ -1109,6 +1114,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry,

return 0;
}
EXPORT_SYMBOL(smp_call_function);

/* Sorry about the name. In an APIC based system, the APICs
* themselves are programmed to send a timer interrupt. This is used
Expand Down
7 changes: 0 additions & 7 deletions trunk/arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,6 @@ config IOSAPIC
depends on !IA64_HP_SIM
default y

config IA64_SGI_SN_SIM
bool "SGI Medusa Simulator Support"
depends on IA64_SGI_SN2 || IA64_GENERIC
help
If you are compiling a kernel that will run under SGI's IA-64
simulator (Medusa) then say Y, otherwise say N.

config IA64_SGI_SN_XP
tristate "Support communication between SGI SSIs"
select IA64_UNCACHED_ALLOCATOR
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/ia64/configs/sn2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ CONFIG_HOLES_IN_ZONE=y
CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
# CONFIG_IA64_CYCLONE is not set
CONFIG_IOSAPIC=y
CONFIG_IA64_SGI_SN_SIM=y
CONFIG_FORCE_MAX_ZONEORDER=18
CONFIG_SMP=y
CONFIG_NR_CPUS=512
Expand Down
Loading

0 comments on commit dc3f99c

Please sign in to comment.