Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\notify\mark.c Create Date:2022-07-28 20:16:35
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Add mark into proper place in given list of marks. These marks may be used* for the fsnotify backend to determine which event types should be delivered* to which group and for which inodes. These marks are ordered according to

Proto:static int fsnotify_add_mark_list(struct fsnotify_mark *mark, fsnotify_connp_t *connp, unsigned int type, int allow_dups, __kernel_fsid_t *fsid)

Type:int

Parameter:

TypeParameterName
struct fsnotify_mark *mark
fsnotify_connp_t *connp
unsigned inttype
intallow_dups
__kernel_fsid_t *fsid
547  struct fsnotify_mark * lmark, * last = NULL
550  err = 0
552  If WARN_ON(!fsnotify_valid_obj_type(type)) Then Return -EINVAL
556  If fsid && WARN_ON_ONCE(!val[0] && !val[1]) Then Return -ENODEV
559  restart :
560  spin_lock( & Protects inode / mnt pointers, flags, masks )
561  conn = Get mark connector, make sure it is alive and return with its lock held.* This is for users that get connector pointer from inode or mount. Users that* hold reference to a mark on the list may directly lock connector->lock as
562  If Not conn Then
563  spin_unlock( & Protects inode / mnt pointers, flags, masks )
564  err = fsnotify_attach_connector_to_object(connp, type, fsid)
565  If err Then Return err
567  Go to restart
568  Else if fsid && Not ( flags [lock] & FSNOTIFY_CONN_FLAG_HAS_FSID) Then
569  fsid of filesystem containing object = fsid
571  smp_wmb()
572  flags [lock] |= FSNOTIFY_CONN_FLAG_HAS_FSID
573  Else if fsid && flags [lock] & FSNOTIFY_CONN_FLAG_HAS_FSID && ( val[0] != val[0] || val[1] != val[1] ) Then
583  pr_warn_ratelimited("%s: fsid mismatch on object of type %u: %x.%x != %x.%x\n", __func__, Type of object [lock] , val[0], val[1], val[0], val[1])
587  err = -EXDEV
588  Go to out_err
592  If hlist_empty( & list) Then
593  adds the specified element to the specified hlist
594  Go to added
599  last = lmark
604  err = -EEXIST
605  Go to out_err
608  cmp = Sorting function for lists of fsnotify marks.* Fanotify supports different notification classes (reflected as priority of* notification group). Events shall be passed to notification groups in* decreasing priority order
609  If cmp >= 0 Then
611  Go to added
615  BUG_ON(last == NULL)
617  hlist_add_behind_rcu*@n: the new element to add to the hash list
618  added :
624  WRITE_ONCE( Head of list of marks for an object [mark ref] , conn)
625  out_err :
626  spin_unlock( & lock)
627  spin_unlock( & Protects inode / mnt pointers, flags, masks )
628  Return err
Caller
NameDescribe
fsnotify_add_mark_lockedAttach an initialized mark to a given group and fs object.* These marks may be used for the fsnotify backend to determine which* event types should be delivered to which group.