Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4888
b: refs/heads/master
c: af6ea9c
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jul 16, 2005
1 parent fdc3594 commit c504cce
Show file tree
Hide file tree
Showing 57 changed files with 709 additions and 531 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: c514720716c7b109ff980f8b3cb93f9af872c91c
refs/heads/master: af6ea9ca23504fe620412826a420dca9c43a8bf6
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
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
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
37 changes: 35 additions & 2 deletions trunk/arch/ia64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* 02/01/00 R.Seth fixed get_cpuinfo for SMP
* 01/07/99 S.Eranian added the support for command line argument
* 06/24/99 W.Drummond added boot_cpu_data.
* 05/28/05 Z. Menyhart Dynamic stride size for "flush_icache_range()"
*/
#include <linux/config.h>
#include <linux/module.h>
Expand Down Expand Up @@ -84,6 +85,13 @@ struct io_space io_space[MAX_IO_SPACES];
EXPORT_SYMBOL(io_space);
unsigned int num_io_spaces;

/*
* "flush_icache_range()" needs to know what processor dependent stride size to use
* when it makes i-cache(s) coherent with d-caches.
*/
#define I_CACHE_STRIDE_SHIFT 5 /* Safest way to go: 32 bytes by 32 bytes */
unsigned long ia64_i_cache_stride_shift = ~0;

/*
* The merge_mask variable needs to be set to (max(iommu_page_size(iommu)) - 1). This
* mask specifies a mask of address bits that must be 0 in order for two buffers to be
Expand Down Expand Up @@ -628,6 +636,12 @@ setup_per_cpu_areas (void)
/* start_kernel() requires this... */
}

/*
* Calculate the max. cache line size.
*
* In addition, the minimum of the i-cache stride sizes is calculated for
* "flush_icache_range()".
*/
static void
get_max_cacheline_size (void)
{
Expand All @@ -641,6 +655,8 @@ get_max_cacheline_size (void)
printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n",
__FUNCTION__, status);
max = SMP_CACHE_BYTES;
/* Safest setup for "flush_icache_range()" */
ia64_i_cache_stride_shift = I_CACHE_STRIDE_SHIFT;
goto out;
}

Expand All @@ -649,14 +665,31 @@ get_max_cacheline_size (void)
&cci);
if (status != 0) {
printk(KERN_ERR
"%s: ia64_pal_cache_config_info(l=%lu) failed (status=%ld)\n",
"%s: ia64_pal_cache_config_info(l=%lu, 2) failed (status=%ld)\n",
__FUNCTION__, l, status);
max = SMP_CACHE_BYTES;
/* The safest setup for "flush_icache_range()" */
cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
cci.pcci_unified = 1;
}
line_size = 1 << cci.pcci_line_size;
if (line_size > max)
max = line_size;
}
if (!cci.pcci_unified) {
status = ia64_pal_cache_config_info(l,
/* cache_type (instruction)= */ 1,
&cci);
if (status != 0) {
printk(KERN_ERR
"%s: ia64_pal_cache_config_info(l=%lu, 1) failed (status=%ld)\n",
__FUNCTION__, l, status);
/* The safest setup for "flush_icache_range()" */
cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
}
}
if (cci.pcci_stride < ia64_i_cache_stride_shift)
ia64_i_cache_stride_shift = cci.pcci_stride;
}
out:
if (max > ia64_max_cacheline_size)
ia64_max_cacheline_size = max;
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/ia64/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ int arch_register_cpu(int num)
parent = &sysfs_nodes[cpu_to_node(num)];
#endif /* CONFIG_NUMA */

#ifdef CONFIG_ACPI_BOOT
/*
* If CPEI cannot be re-targetted, and this is
* CPEI target, then dont create the control file
*/
if (!can_cpei_retarget() && is_cpu_cpei_target(num))
sysfs_cpus[num].cpu.no_control = 1;
#endif

return register_cpu(&sysfs_cpus[num].cpu, num, parent);
}
Expand Down
46 changes: 34 additions & 12 deletions trunk/arch/ia64/lib/flush.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,59 @@
*
* Copyright (C) 1999-2001, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com>
*
* 05/28/05 Zoltan Menyhart Dynamic stride size
*/

#include <asm/asmmacro.h>
#include <asm/page.h>


/*
* flush_icache_range(start,end)
* Must flush range from start to end-1 but nothing else (need to
*
* Make i-cache(s) coherent with d-caches.
*
* Must deal with range from start to end-1 but nothing else (need to
* be careful not to touch addresses that may be unmapped).
*
* Note: "in0" and "in1" are preserved for debugging purposes.
*/
GLOBAL_ENTRY(flush_icache_range)

.prologue
alloc r2=ar.pfs,2,0,0,0
sub r8=in1,in0,1
alloc r2=ar.pfs,2,0,0,0
movl r3=ia64_i_cache_stride_shift
mov r21=1
;;
ld8 r20=[r3] // r20: stride shift
sub r22=in1,r0,1 // last byte address
;;
shr.u r8=r8,5 // we flush 32 bytes per iteration
.save ar.lc, r3
mov r3=ar.lc // save ar.lc
shr.u r23=in0,r20 // start / (stride size)
shr.u r22=r22,r20 // (last byte address) / (stride size)
shl r21=r21,r20 // r21: stride size of the i-cache(s)
;;
sub r8=r22,r23 // number of strides - 1
shl r24=r23,r20 // r24: addresses for "fc.i" =
// "start" rounded down to stride boundary
.save ar.lc,r3
mov r3=ar.lc // save ar.lc
;;

.body

mov ar.lc=r8
mov ar.lc=r8
;;
.Loop: fc.i in0 // issuable on M2 only
add in0=32,in0
/*
* 32 byte aligned loop, even number of (actually 2) bundles
*/
.Loop: fc.i r24 // issuable on M0 only
add r24=r21,r24 // we flush "stride size" bytes per iteration
nop.i 0
br.cloop.sptk.few .Loop
;;
sync.i
;;
srlz.i
;;
mov ar.lc=r3 // restore ar.lc
mov ar.lc=r3 // restore ar.lc
br.ret.sptk.many rp
END(flush_icache_range)
Loading

0 comments on commit c504cce

Please sign in to comment.