Skip to contentSkip to conversation

Inotify: nested attributes support.

take2 Evgeniy Polyakov 4 participants 14 messages Nov 25, 2008 – Dec 4, 2008

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi.

Attached patch (also attached test application) implementes scalable nested attributes which are transferred on behalf the inotify mechanism. It uses inotify_init1() to show that new event format should be returned when reading from inotify file descriptor.

Attributes are attached to given inotify instance via TIOCSETD ioctl, where ID of the attribute is transferred. If entry with given ID exists, it is removed and -EEXIST is returned.

There is a set of callbacks indexed by ID (currently 4 attributes are
supported: pid, tid, io details (start/size of the written block) and name), which are attached to given inotify device.
When new event is created, each callback is executed and may queue some data into event structure, based on its internal details. When event is read from the userspace, first its header is transferred (old inotify_event structure) and then all attributes data in the order of its registration via above ioctl. Nested attributes have following structure:

struct inotify_attribute

{
	unsigned int		id;
	unsigned int		size;
	unsigned char		data[0];
};

where size is nuber of attached bytes for given attribute. inotify_event.len contains number of bytes used to store all attached attributes and data.

Attribute callback can check if mask contains its bits and do some steps based on that information, for example io details attribute does not add own data (and header) if event mask does not contain IN_MODIFY bit.

It is possible to infinitely extend number of attributes processed, so we will be no longer limited by inotify API and ABI.

Test application usage:

$ gcc ./iotest.c -W -Wall -I/path/to/kernel/include/ -o iotest
$ ./iotest -f /tmp/ -t -n -p -i
2008-11-25 22:29:47.8477 pid: 1850, tid: 1850, name: /tmp/, wd: 1, mask: 303, attributes: pid: 1, tid: 1, io: 1, name: 1.
event: 2, wd: 1, cookie: 0, len: 61.
	tid: 1672.
	pid: 1672.
	io details: start: 0, size: 0.
	name: test.
event: 2, wd: 1, cookie: 0, len: 61.
	tid: 1672.
	pid: 1672.
	io details: start: 0, size: 6.
	name: test.

Example with only tid and io details:

$ $ ./iotest -f /tmp/ -t -i
2008-11-25 22:40:30.201286 pid: 1928, tid: 1928, name: /tmp/, wd: 1,
mask: 303, attributes: pid: 0, tid: 1, io: 1, name: 0.
event: 2, wd: 1, cookie: 0, len: 36.
	tid: 1672.
	io details: start: 0, size: 0.

while in parallel I did:

$ echo qwe11 > /tmp/test

Two events were sent because of two calls for fsnotify_modify(), invoked lkely from attribute change and write. Events are not combined since because attributes may be different. Not having a name always combines (read: skips next event) events because of old logic.

 fs/compat.c              |    2 +-
 fs/inotify.c             |   23 ++--
 fs/inotify_user.c        |  300 ++++++++++++++++++++++++++++++++++++++++------
 fs/nfsd/vfs.c            |    2 +-
 fs/read_write.c          |    4 +-
 include/linux/fsnotify.h |  105 ++++++++++-------
 include/linux/inotify.h  |   50 +++++++-
 7 files changed, 382 insertions(+), 104 deletions(-)
fs/compat.c +1 -1
index e5f49f5..43f4d73 100644
@@ -1162,7 +1162,7 @@ out:
 		if (type == READ)
 			fsnotify_access(dentry);
 		else
-			fsnotify_modify(dentry);
+			fsnotify_modify(dentry, *pos - ret, ret);
 	}
 	return ret;
 }
fs/inotify.c +11 -12
index 7bbed1b..b56cefc 100644
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
+#include <linux/fsnotify.h>
 #include <linux/idr.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
@@ -251,8 +252,9 @@ static void remove_watch_no_event(struct inotify_watch *watch,
 void inotify_remove_watch_locked(struct inotify_handle *ih,
 				 struct inotify_watch *watch)
 {
+	INOTIFY_DETAILS(det, IN_IGNORED, 0, NULL);
 	remove_watch_no_event(watch, ih);
-	ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL, NULL);
+	ih->in_ops->handle_event(watch, watch->wd, &det, NULL);
 }
 EXPORT_SYMBOL_GPL(inotify_remove_watch_locked);
 
@@ -297,8 +299,8 @@ void inotify_d_move(struct dentry *entry)
  * @name: filename, if any
  * @n_inode: inode associated with name
  */
-void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
-			       const char *name, struct inode *n_inode)
+void inotify_inode_queue_event(struct inode *inode, struct inotify_details *det,
+		struct inode *n_inode)
 {
 	struct inotify_watch *watch, *next;
 
@@ -308,13 +310,12 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
 	mutex_lock(&inode->inotify_mutex);
 	list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
 		u32 watch_mask = watch->mask;
-		if (watch_mask & mask) {
+		if (watch_mask & det->mask) {
 			struct inotify_handle *ih= watch->ih;
 			mutex_lock(&ih->mutex);
 			if (watch_mask & IN_ONESHOT)
 				remove_watch_no_event(watch, ih);
-			ih->in_ops->handle_event(watch, watch->wd, mask, cookie,
-						 name, n_inode);
+			ih->in_ops->handle_event(watch, watch->wd, det, n_inode);
 			mutex_unlock(&ih->mutex);
 		}
 	}
@@ -329,8 +330,7 @@ EXPORT_SYMBOL_GPL(inotify_inode_queue_event);
  * @cookie: cookie for synchronization, or zero
  * @name: filename, if any
  */
-void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
-				       u32 cookie, const char *name)
+void inotify_dentry_parent_queue_event(struct dentry *dentry, struct inotify_details *det)
 {
 	struct dentry *parent;
 	struct inode *inode;
@@ -345,8 +345,7 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
 	if (inotify_inode_watched(inode)) {
 		dget(parent);
 		spin_unlock(&dentry->d_lock);
-		inotify_inode_queue_event(inode, mask, cookie, name,
-					  dentry->d_inode);
+		inotify_inode_queue_event(inode, det, dentry->d_inode);
 		dput(parent);
 	} else
 		spin_unlock(&dentry->d_lock);
@@ -428,9 +427,9 @@ void inotify_unmount_inodes(struct list_head *list)
 		watches = &inode->inotify_watches;
 		list_for_each_entry_safe(watch, next_w, watches, i_list) {
 			struct inotify_handle *ih= watch->ih;
+			INOTIFY_DETAILS(det, IN_UNMOUNT, 0, NULL);
 			mutex_lock(&ih->mutex);
-			ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0,
-						 NULL, NULL);
+			ih->in_ops->handle_event(watch, watch->wd, &det, NULL);
 			inotify_remove_watch_locked(ih, watch);
 			mutex_unlock(&ih->mutex);
 		}
fs/inotify_user.c +262 -38

446 lines not on this page · raw message

fs/nfsd/vfs.c +1 -1
index 4433c8f..d3e4adc 100644
@@ -1007,7 +1007,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
 	set_fs(oldfs);
 	if (host_err >= 0) {
 		nfsdstats.io_write += cnt;
-		fsnotify_modify(file->f_path.dentry);
+		fsnotify_modify(file->f_path.dentry, offset-cnt, cnt);
 	}
 
 	/* clear setuid/setgid flag after write */
fs/read_write.c +2 -2
index 969a6d9..5c521c2 100644
@@ -335,7 +335,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
 		else
 			ret = do_sync_write(file, buf, count, pos);
 		if (ret > 0) {
-			fsnotify_modify(file->f_path.dentry);
+			fsnotify_modify(file->f_path.dentry, *pos - ret, ret);
 			add_wchar(current, ret);
 		}
 		inc_syscw(current);
@@ -628,7 +628,7 @@ out:
 		if (type == READ)
 			fsnotify_access(file->f_path.dentry);
 		else
-			fsnotify_modify(file->f_path.dentry);
+			fsnotify_modify(file->f_path.dentry, *pos - ret, ret);
 	}
 	return ret;
 }
include/linux/fsnotify.h +62 -43

226 lines not on this page · raw message

include/linux/inotify.h +43 -7

75 lines not on this page · raw message

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

[take2] Inotify: nested attributes test application.

$ ./iotest -h
Usage: ./iotest -f path -t <tid> -p <pid> -i <io details> -n <name> -h <help>
$ ./iotest -f /tmp/ -t -i
2008-11-25 22:40:30.201286 pid: 1928, tid: 1928, name: /tmp/, wd: 1, mask: 303, attributes: pid: 0, tid: 1, io: 1, name: 0.
event: 2, wd: 1, cookie: 0, len: 36.
	tid: 1672.
	io details: start: 0, size: 0.
$ echo qwe11 > /tmp/test
Signature · 1 line
	Evgeniy Polyakov

/*
* 2007+ Copyright (c) Evgeniy Polyakov <[email protected]>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#define _GNU_SOURCE
#define __USE_FILE_OFFSET64
#define __USE_LARGEFILE64
#define _FILE_OFFSET_BITS 64

#include <sys/ioctl.h>
#include <sys/time.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <stdarg.h>

#include <linux/types.h>
#include <linux/inotify.h>
#include <linux/unistd.h>

#include <asm/unistd.h>

extern int inotify_add_watch(int __fd, const char *__name, unsigned int __mask);

void iotest_log(const char *f, ...)

{
	char str[64];
	struct tm tm;
	struct timeval tv;
	va_list ap;

	gettimeofday(&tv, NULL);
	localtime_r((time_t *)&tv.tv_sec, &tm);
	strftime(str, sizeof(str), "%F %R:%S", &tm);

	fprintf(stderr, "%s.%lu ", str, tv.tv_usec);

	va_start(ap, f);
	vfprintf(stderr, f, ap);
	va_end(ap);

	fflush(stderr);
}

#define iotest_err(f, a...) iotest_log(f ": %s [%d].\n", ##a, strerror(errno), errno)

static void iotest_usage(char *p)

{
	fprintf(stderr, "Usage: %s -f path -t <tid> -p <pid> -i <io details> -n <name> -h <help>\n", p);
}

int main(int argc, char *argv[])

{
	int fd, ch, err;
	int tid, pid, io, name, wd;
	char *file;
	unsigned int mask;
	char buf[4096];
	void *data;
	struct inotify_event *e;
	struct inotify_attribute *a;
	struct inotify_io_details *det;
	unsigned int id;

	file = NULL;
	tid = 0;
	pid = 0;
	io = 0;
	name = 0;

	while ((ch = getopt(argc, argv, "f:tpinh")) != -1) {
		switch (ch) {
			case 'f':
				file = optarg;
				break;
			case 't':
				tid = 1;
				break;
			case 'p':
				pid = 1;
				break;
			case 'i':
				io = 1;
				break;
			case 'n':
				name = 1;
				break;
			case 'h':
			default:
				iotest_usage(argv[0]);
				return -1;
		}
	}

	if (!file) {
		fprintf(stderr, "You have to provide file to watch IO against.\n");
		iotest_usage(argv[0]);
		return -1;
	}

	fd = syscall(__NR_inotify_init1, IN_ATTRS);
	if (fd < 0) {
		iotest_err("Failed to call inotify_init1");
		return -1;
	}

	if (tid) {
		id = INOTIFY_ATTR_TID;
		err = ioctl(fd, TIOCSETD, &id, 4);
		if (err) {
			iotest_err("Failed to setup TID attribute");
			return err;
		}
	}
	
	if (pid) {
		id = INOTIFY_ATTR_PID;
		err = ioctl(fd, TIOCSETD, &id, 4);
		if (err) {
			iotest_err("Failed to setup PID attribute");
			return err;
		}
	}
	
	if (io) {
		id = INOTIFY_ATTR_IO;
		err = ioctl(fd, TIOCSETD, &id, 4);
		if (err) {
			iotest_err("Failed to setup IO attribute");
			return err;
		}
	}
	
	if (name) {
		id = INOTIFY_ATTR_NAME;
		err = ioctl(fd, TIOCSETD, &id, 4);
		if (err) {
			iotest_err("Failed to setup name attribute");
			return err;
		}
	}

	mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_ACCESS;
	wd = inotify_add_watch(fd, file, mask);
	if (wd < 0) {
		iotest_err("Failed to add %x watch for file '%s'", mask, file);
		return -1;
	}

	iotest_log("pid: %d, tid: %d, name: %s, wd: %d, mask: %x, attributes: "
			"pid: %d, tid: %d, io: %d, name: %d.\n",
			getpid(), syscall(__NR_gettid), file, wd, mask,
			pid, tid, io, name);

	while (1) {
		sleep(5);
		data = buf;
		err = read(fd, buf, sizeof(buf));
		if (err <= 0) {
			iotest_err("Failed to read event");
			return err;
		}

		e = data;
		printf("event: %x, wd: %d, cookie: %u, len: %u.\n", e->mask, e->wd, e->cookie, e->len);

		data += sizeof(struct inotify_event);
		while (e->len) {
			a = data;

			switch (a->id) {
				case INOTIFY_ATTR_PID:
					id = *(unsigned int *)a->data;
					printf("       pid: %u.\n", id);
					break;
				case INOTIFY_ATTR_TID:
					id = *(unsigned int *)a->data;
					printf("       tid: %u.\n", id);
					break;
				case INOTIFY_ATTR_IO:
					det = (struct inotify_io_details *)a->data;
					printf("       io details: start: %llu, size: %llu.\n",
							(unsigned long long)det->start,
							(unsigned long long)det->size);
					break;
				case INOTIFY_ATTR_NAME:
					printf("       name: %s.\n", (char *)a->data);
					break;
				default:
					printf("       unsupported id: %u, size: %u.\n", a->id, a->size);
					break;
			}

			data += a->size + sizeof(struct inotify_attribute);
			e->len -= a->size + sizeof(struct inotify_attribute);
		}
	}

	close(fd);
	return 0;
}
#2 lore raw
In reply to Evgeniy Polyakov
Quoted 63 lines · On Tue, 25 Nov 2008 22:42:35 +0300 Evgeniy Polyakov…

Hi.

Attached patch (also attached test application) implementes scalable nested attributes which are transferred on behalf the inotify mechanism. It uses inotify_init1() to show that new event format should be returned when reading from inotify file descriptor.

Attributes are attached to given inotify instance via TIOCSETD ioctl, where ID of the attribute is transferred. If entry with given ID exists, it is removed and -EEXIST is returned.

There is a set of callbacks indexed by ID (currently 4 attributes are
supported: pid, tid, io details (start/size of the written block) and name), which are attached to given inotify device.
When new event is created, each callback is executed and may queue some data into event structure, based on its internal details. When event is read from the userspace, first its header is transferred (old inotify_event structure) and then all attributes data in the order of its registration via above ioctl. Nested attributes have following structure:

struct inotify_attribute

{
	unsigned int		id;
	unsigned int		size;
	unsigned char		data[0];
};

where size is nuber of attached bytes for given attribute. inotify_event.len contains number of bytes used to store all attached attributes and data.

Attribute callback can check if mask contains its bits and do some steps based on that information, for example io details attribute does not add own data (and header) if event mask does not contain IN_MODIFY bit.

It is possible to infinitely extend number of attributes processed, so we will be no longer limited by inotify API and ABI.

Test application usage:

$ gcc ./iotest.c -W -Wall -I/path/to/kernel/include/ -o iotest
$ ./iotest -f /tmp/ -t -n -p -i
2008-11-25 22:29:47.8477 pid: 1850, tid: 1850, name: /tmp/, wd: 1, mask: 303, attributes: pid: 1, tid: 1, io: 1, name: 1.
event: 2, wd: 1, cookie: 0, len: 61.
	tid: 1672.
	pid: 1672.
	io details: start: 0, size: 0.
	name: test.
event: 2, wd: 1, cookie: 0, len: 61.
	tid: 1672.
	pid: 1672.
	io details: start: 0, size: 6.
	name: test.

Example with only tid and io details:

$ $ ./iotest -f /tmp/ -t -i
2008-11-25 22:40:30.201286 pid: 1928, tid: 1928, name: /tmp/, wd: 1,
mask: 303, attributes: pid: 0, tid: 1, io: 1, name: 0.
event: 2, wd: 1, cookie: 0, len: 36.
	tid: 1672.
	io details: start: 0, size: 0.
Quoted 8 lines

while in parallel I did:

$ echo qwe11 > /tmp/test

Two events were sent because of two calls for fsnotify_modify(), invoked lkely from attribute change and write. Events are not combined since because attributes may be different. Not having a name always combines (read: skips next event) events because of old logic.

I guess I'm being more than usually thick, but I don't understand what this is all about, why it was implemented, what value it provides to users, etc, etc? Why do I want scalable nested attributes in inotify??

I'm buried in patches which I don't understand lately, and having hundreds of people send patches at one guy who doesn't understand them isn't a good system. Eric Paris is working on inotify-type things as well. It would be neat if you guys were to understand and review each other's work. Please.

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Hi Andrew.

Quoted 3 lines · Andrew Morton

I guess I'm being more than usually thick, but I don't understand what this is all about, why it was implemented, what value it provides to users, etc, etc? Why do I want scalable nested attributes in inotify??

Originally I just wanted to have a PID value in the inotify events, so reused cookie for that, but people rather vocally rised against this. So solution is to extend its structure. It would be possible just to add couple more bytes and store data there, but if we will want to add some more data into event later, we will have to implement inotify3 and so on. So I implemented a way to put essentially any number of new and old events in any order, turn then on and off, and do not care about possible limitation of the structure. As example I added PID, TID, write IO start/size and name attributes.

Quoted 5 lines

I'm buried in patches which I don't understand lately, and having hundreds of people send patches at one guy who doesn't understand them isn't a good system. Eric Paris is working on inotify-type things as well. It would be neat if you guys were to understand and review each other's work. Please.

No problem, I will review patches if added to the copy. I'm not subscsribed to linux-kernel@ so will miss them otherwise.

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 7 lines · On Wed, 26 Nov 2008 10:42:39 +0300 Evgeniy Polyakov…

Hi Andrew.

Quoted 3 lines · Andrew Morton

I guess I'm being more than usually thick, but I don't understand what this is all about, why it was implemented, what value it provides to users, etc, etc? Why do I want scalable nested attributes in inotify??

Quoted 9 lines

Originally I just wanted to have a PID value in the inotify events, so reused cookie for that, but people rather vocally rised against this. So solution is to extend its structure. It would be possible just to add couple more bytes and store data there, but if we will want to add some more data into event later, we will have to implement inotify3 and so on. So I implemented a way to put essentially any number of new and old events in any order, turn then on and off, and do not care about possible limitation of the structure. As example I added PID, TID, write IO start/size and name attributes.

OK, so we have a super-duper framework which will allow us to add pids (and other things) to inotify messages.

This still doesn't provide a reason for anyone to be interested in the code! Why do we want pids in inotify messages?

And how does this work give that pids are (no longer) system-wide unique?

Quoted 8 lines
Quoted 5 lines

I'm buried in patches which I don't understand lately, and having hundreds of people send patches at one guy who doesn't understand them isn't a good system. Eric Paris is working on inotify-type things as well. It would be neat if you guys were to understand and review each other's work. Please.

No problem, I will review patches if added to the copy. I'm not subscsribed to linux-kernel@ so will miss them otherwise.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 2 lines · Andrew Morton

OK, so we have a super-duper framework which will allow us to add pids (and other things) to inotify messages.

Yup :)

Quoted 2 lines

This still doesn't provide a reason for anyone to be interested in the code! Why do we want pids in inotify messages?

I actually cared only about myself :)
I started the thread and implementation, because my application has to differentiate IO made by itself and any IO made by system (another users, crons, whatever else), inotify did not give me that info, so I extended it. As of others: PID/TID may be used by watching applications to reduce own load to not process own IO, things like beagle may show who actually made changes into the file.

Quoted 1 line

And how does this work give that pids are (no longer) system-wide unique?

It gets pids from the caller's task_struct (via current), so its data is as unique as process calling getpid() or syscall(__NR_gettid).

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
Quoted 9 lines · On Wed, 26 Nov 2008 11:29:36 +0300 Evgeniy Polyakov…
Quoted 2 lines · Andrew Morton

OK, so we have a super-duper framework which will allow us to add pids (and other things) to inotify messages.

Yup :)

Quoted 2 lines

This still doesn't provide a reason for anyone to be interested in the code! Why do we want pids in inotify messages?

Quoted 7 lines

I actually cared only about myself :)
I started the thread and implementation, because my application has to differentiate IO made by itself and any IO made by system (another users, crons, whatever else), inotify did not give me that info, so I extended it. As of others: PID/TID may be used by watching applications to reduce own load to not process own IO, things like beagle may show who actually made changes into the file.

hrm. Well this is the sort of information which reviewers want to know all about before looking at an implementation.

Quoted 4 lines
Quoted 1 line

And how does this work give that pids are (no longer) system-wide unique?

It gets pids from the caller's task_struct (via current), so its data is as unique as process calling getpid() or syscall(__NR_gettid).

That means that the code delivers non-unique process identifiers to userspace. A client gets pid=42 but there are seven processes on the machine with that pid. Problem.

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 3 lines · Andrew Morton

That means that the code delivers non-unique process identifiers to userspace. A client gets pid=42 but there are seven processes on the machine with that pid. Problem.

Because of namespaces I suppose? This is not a problem for those who run in the same namespace, otherwise we can add nsproxy ID if needed for anyone.

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw
In reply to Evgeniy Polyakov
Quoted 9 lines · Evgeniy Polyakov
Quoted 3 lines · Andrew Morton

This still doesn't provide a reason for anyone to be interested in the code! Why do we want pids in inotify messages?

my application has to
differentiate IO made by itself and any IO made by system (another users, crons, whatever else)

I don't think so. As discussed,
(http://marc.info/?l=linux-kernel&m=122735413932519), you already can differentiate I/O made by local users, so you don't need to modify inotify.

This change violates my first rule of programming: If there's two or more ways of solving a problem, pick one; don't pick them all. --
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 3 lines · David Newall

I don't think so. As discussed,
(http://marc.info/?l=linux-kernel&m=122735413932519), you already can differentiate I/O made by local users, so you don't need to modify inotify.

And as was shown it does not work for all cases and introduces unneded performance overhead.

Quoted 2 lines

This change violates my first rule of programming: If there's two or more ways of solving a problem, pick one; don't pick them all.

Then we should go back to caves, raw meat was so tasty...

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
Quoted 10 lines · Evgeniy Polyakov
Quoted 4 lines · David Newall

I don't think so. As discussed,
(http://marc.info/?l=linux-kernel&m=122735413932519), you already can differentiate I/O made by local users, so you don't need to modify inotify.

And as was shown it does not work for all cases and introduces unneded performance overhead.

If the performance using a local loopback is insufficient, or even when using a UNIX domain socket, then it's going to be even worse for the actual network-connected clients. And the cases were it doesn't work amount to poor system administration, which is a solvable problem.

Quoted 5 lines
Quoted 3 lines

This change violates my first rule of programming: If there's two or more ways of solving a problem, pick one; don't pick them all.

Then we should go back to caves, raw meat was so tasty...

Amusing, but irrelevant to programming.
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
Quoted 7 lines · David Newall
Quoted 2 lines

And as was shown it does not work for all cases and introduces unneded performance overhead.

If the performance using a local loopback is insufficient, or even when using a UNIX domain socket, then it's going to be even worse for the actual network-connected clients. And the cases were it doesn't work amount to poor system administration, which is a solvable problem.

Proposing to introduce additional overhead when it can be avoided is not the best way to deal with the problem.
Another small detail, that it does not completely solve the problem.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This change violates my first rule of programming: If there's two or more ways of solving a problem, pick one; don't pick them all.

Then we should go back to caves, raw meat was so tasty...

Amusing, but irrelevant to programming.

Programming is so special, that new things which help having a progress should not be developed there? Care to recall how to work with the punch card? Following your logic inotify should be returned from the kernel, since all applications which may do IO can be modified to first register it in some special database and not checking IO at run-time. And we will not care about others who did not do that.

Your 'rule' does not apply to the case, where is no way to solve the problem completely using existing methods.

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
In reply to Evgeniy Polyakov
Quoted 9 lines · Evgeniy Polyakov
Quoted 2 lines · Andrew Morton

OK, so we have a super-duper framework which will allow us to add pids (and other things) to inotify messages.

Yup :)

Quoted 2 lines

This still doesn't provide a reason for anyone to be interested in the code! Why do we want pids in inotify messages?

Quoted 7 lines

I actually cared only about myself :)
I started the thread and implementation, because my application has to differentiate IO made by itself and any IO made by system (another users, crons, whatever else), inotify did not give me that info, so I extended it. As of others: PID/TID may be used by watching applications to reduce own load to not process own IO, things like beagle may show who actually made changes into the file.

Actually, does the kernel even know who initiated the i/o?

Take two threads, both mapping /etc/something , both of them writing through the mmap. Kernel sees dirty pages so it writes them back, but which thread is repsonsible for the write?

Quoted 4 lines
Quoted 1 line

And how does this work give that pids are (no longer) system-wide unique?

It gets pids from the caller's task_struct (via current), so its data is as unique as process calling getpid() or syscall(__NR_gettid).

What happens on mmap()?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#13 lore raw
Quoted 5 lines · Pavel Machek

Actually, does the kernel even know who initiated the i/o?

Take two threads, both mapping /etc/something , both of them writing through the mmap. Kernel sees dirty pages so it writes them back, but which thread is repsonsible for the write?

It depends. If write will be done with write() syscall, caller will be stored. Otherwise inotify does not hook into page fault code afaics.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

And how does this work give that pids are (no longer) system-wide unique?

It gets pids from the caller's task_struct (via current), so its data is as unique as process calling getpid() or syscall(__NR_gettid).

What happens on mmap()?

mmap() syscall is not processed by inotify.

Signature · 5 lines
	Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html