Skip to content

Commit

Permalink
Merge with rsync://fileserver/linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Gleixner authored and Thomas Gleixner committed Jul 16, 2005
2 parents 5d15788 + d6e1860 commit 2c4eec9
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 147 deletions.
77 changes: 45 additions & 32 deletions 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.

6 changes: 6 additions & 0 deletions 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
1 change: 1 addition & 0 deletions 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
2 changes: 2 additions & 0 deletions 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
3 changes: 2 additions & 1 deletion drivers/char/rocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void rp_do_receive(struct r_port *info,
ToRecv = space;

if (ToRecv <= 0)
return;
goto done;

/*
* if status indicates there are errored characters in the
Expand Down Expand Up @@ -437,6 +437,7 @@ static void rp_do_receive(struct r_port *info,
}
/* Push the data up to the tty layer */
ld->receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count);
done:
tty_ldisc_deref(ld);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ void do_blank_screen(int entering_gfx)
return;

if (vesa_off_interval) {
blank_state = blank_vesa_wait,
blank_state = blank_vesa_wait;
mod_timer(&console_timer, jiffies + vesa_off_interval);
}

Expand Down
9 changes: 6 additions & 3 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
}
}

int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
int degraded)
{
bitmap_counter_t *bmc;
int rv;
Expand All @@ -1362,8 +1363,10 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
rv = 1;
else if (NEEDED(*bmc)) {
rv = 1;
*bmc |= RESYNC_MASK;
*bmc &= ~NEEDED_MASK;
if (!degraded) { /* don't set/clear bits if degraded */
*bmc |= RESYNC_MASK;
*bmc &= ~NEEDED_MASK;
}
}
}
spin_unlock_irq(&bitmap->lock);
Expand Down
8 changes: 4 additions & 4 deletions drivers/md/raid0.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,16 @@ static int raid0_run (mddev_t *mddev)
sector_t space = conf->hash_spacing;
int round;
conf->preshift = 0;
if (sizeof(sector_t) > sizeof(unsigned long)) {
if (sizeof(sector_t) > sizeof(u32)) {
/*shift down space and s so that sector_div will work */
while (space > (sector_t) (~(unsigned long)0)) {
while (space > (sector_t) (~(u32)0)) {
s >>= 1;
space >>= 1;
s += 1; /* force round-up */
conf->preshift++;
}
}
round = sector_div(s, (unsigned long)space) ? 1 : 0;
round = sector_div(s, (u32)space) ? 1 : 0;
nb_zone = s + round;
}
printk("raid0 : nb_zone is %d.\n", nb_zone);
Expand Down Expand Up @@ -443,7 +443,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
volatile
#endif
sector_t x = block >> conf->preshift;
sector_div(x, (unsigned long)conf->hash_spacing);
sector_div(x, (u32)conf->hash_spacing);
zone = conf->hash_table[x];
}

Expand Down
37 changes: 18 additions & 19 deletions drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,21 +1126,19 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
* only be one in raid1 resync.
* We can find the current addess in mddev->curr_resync
*/
if (!conf->fullsync) {
if (mddev->curr_resync < max_sector)
bitmap_end_sync(mddev->bitmap,
mddev->curr_resync,
if (mddev->curr_resync < max_sector) /* aborted */
bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
&sync_blocks, 1);
bitmap_close_sync(mddev->bitmap);
}
if (mddev->curr_resync >= max_sector)
else /* completed sync */
conf->fullsync = 0;

bitmap_close_sync(mddev->bitmap);
close_sync(conf);
return 0;
}

if (!conf->fullsync &&
!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks)) {
if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, mddev->degraded) &&
!conf->fullsync) {
/* We can skip this block, and probably several more */
*skipped = 1;
return sync_blocks;
Expand Down Expand Up @@ -1243,15 +1241,15 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
len = (max_sector - sector_nr) << 9;
if (len == 0)
break;
if (!conf->fullsync) {
if (sync_blocks == 0) {
if (!bitmap_start_sync(mddev->bitmap,
sector_nr, &sync_blocks))
break;
if (sync_blocks < (PAGE_SIZE>>9))
BUG();
if (len > (sync_blocks<<9)) len = sync_blocks<<9;
}
if (sync_blocks == 0) {
if (!bitmap_start_sync(mddev->bitmap, sector_nr,
&sync_blocks, mddev->degraded) &&
!conf->fullsync)
break;
if (sync_blocks < (PAGE_SIZE>>9))
BUG();
if (len > (sync_blocks<<9))
len = sync_blocks<<9;
}

for (i=0 ; i < conf->raid_disks; i++) {
Expand All @@ -1264,7 +1262,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
while (i > 0) {
i--;
bio = r1_bio->bios[i];
if (bio->bi_end_io==NULL) continue;
if (bio->bi_end_io==NULL)
continue;
/* remove last page from this bio */
bio->bi_vcnt--;
bio->bi_size -= len;
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/cx88/cx88-cards.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-cards.c,v 1.85 2005/07/04 19:35:05 mkrufky Exp $
* $Id: cx88-cards.c,v 1.86 2005/07/14 03:06:43 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* card-specific stuff.
Expand Down Expand Up @@ -682,9 +682,9 @@ struct cx88_board cx88_boards[] = {
.name = "PixelView PlayTV Ultra Pro (Stereo)",
/* May be also TUNER_YMEC_TVF_5533MF for NTSC/M or PAL/M */
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
.radio_type = TUNER_TEA5767,
.tuner_addr = 0xc2>>1,
.radio_addr = 0xc0>>1,
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
.input = {{
.type = CX88_VMUX_TELEVISION,
.vmux = 0,
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/cx88/cx88-dvb.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-dvb.c,v 1.41 2005/07/04 19:35:05 mkrufky Exp $
* $Id: cx88-dvb.c,v 1.42 2005/07/12 15:44:55 mkrufky Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
Expand Down Expand Up @@ -180,12 +180,14 @@ static struct mt352_config dntv_live_dvbt_config = {
#if CONFIG_DVB_CX22702
static struct cx22702_config connexant_refboard_config = {
.demod_address = 0x43,
.output_mode = CX22702_SERIAL_OUTPUT,
.pll_address = 0x60,
.pll_desc = &dvb_pll_thomson_dtt7579,
};

static struct cx22702_config hauppauge_novat_config = {
.demod_address = 0x43,
.output_mode = CX22702_SERIAL_OUTPUT,
.pll_address = 0x61,
.pll_desc = &dvb_pll_thomson_dtt759x,
};
Expand Down
7 changes: 6 additions & 1 deletion drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: cx88-video.c,v 1.79 2005/07/07 14:17:47 mchehab Exp $
* $Id: cx88-video.c,v 1.80 2005/07/13 08:49:08 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* video4linux video interface
Expand Down Expand Up @@ -1346,6 +1346,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
dev->freq = f->frequency;
cx88_newstation(core);
cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);

/* When changing channels it is required to reset TVAUDIO */
msleep (10);
cx88_set_tvaudio(core);

up(&dev->lock);
return 0;
}
Expand Down
Loading

0 comments on commit 2c4eec9

Please sign in to comment.