History

fanotify: update connector fsid cache on add mark

When implementing connector fsid cache, we only initialized the cache when the first mark added to object was added by FAN_REPORT_FID group. We forgot to update conn->fsid when the second mark is added by FAN_REPORT_FID group to an already attached connector without fsid cache.

Amir Goldstein committed 7 years ago

Commit c285a2f1 parent c6d9c353 files · +18 −4Browse files

Unified · Split

3 files
  1. fs/notify/fanotify/fanotify.c +4 −0
  2. fs/notify/mark.c +11 −3
  3. include/linux/fsnotify_backend.h +3 −1
fs/notify/fanotify/fanotify.c+4−0
@@ -355,6 +355,10 @@ static __kernel_fsid_t fanotify_get_fsid(struct fsnotify_iter_info *iter_info) · 354 unmodified lines
355355 /* Mark is just getting destroyed or created? */
356356 if (!conn)
357357 continue;
358+ if (!(conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID))
359+ continue;
360+ /* Pairs with smp_wmb() in fsnotify_add_mark_list() */
361+ smp_rmb();
358362 fsid = conn->fsid;
359363 if (WARN_ON_ONCE(!fsid.val[0] && !fsid.val[1]))
360364 continue;
fs/notify/mark.c+11−3
@@ -482,10 +482,13 @@ static int fsnotify_attach_connector_to_object(fsnotify_connp_t *connp, · 481 unmodified lines
482482 conn->type = type;
483483 conn->obj = connp;
484484 /* Cache fsid of filesystem containing the object */
485− if (fsid)
485+ if (fsid) {
486486 conn->fsid = *fsid;
487− else
487+ conn->flags = FSNOTIFY_CONN_FLAG_HAS_FSID;
488+ } else {
488489 conn->fsid.val[0] = conn->fsid.val[1] = 0;
490+ conn->flags = 0;
491+ }
489492 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
490493 inode = igrab(fsnotify_conn_inode(conn));
491494 /*
@@ -560,7 +563,12 @@ restart: · 68 unmodified lines
560563 if (err)
561564 return err;
562565 goto restart;
563− } else if (fsid && (conn->fsid.val[0] || conn->fsid.val[1]) &&
566+ } else if (fsid && !(conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID)) {
567+ conn->fsid = *fsid;
568+ /* Pairs with smp_rmb() in fanotify_get_fsid() */
569+ smp_wmb();
570+ conn->flags |= FSNOTIFY_CONN_FLAG_HAS_FSID;
571+ } else if (fsid && (conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID) &&
564572 (fsid->val[0] != conn->fsid.val[0] ||
565573 fsid->val[1] != conn->fsid.val[1])) {
566574 /*
include/linux/fsnotify_backend.h+3−1
@@ -292,7 +292,9 @@ typedef struct fsnotify_mark_connector __rcu *fsnotify_connp_t; · 291 unmodified lines
292292 */
293293 struct fsnotify_mark_connector {
294294 spinlock_t lock;
295− unsigned int type; /* Type of object [lock] */
295+ unsigned short type; /* Type of object [lock] */
296+#define FSNOTIFY_CONN_FLAG_HAS_FSID 0x01
297+ unsigned short flags; /* flags [lock] */
296298 __kernel_fsid_t fsid; /* fsid of filesystem containing object */
297299 union {
298300 /* Object pointer [lock] */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t