UPSTREAM: dentry name snapshots

take_dentry_name_snapshot() takes a safe snapshot of dentry name;
if the name is a short one, it gets copied into caller-supplied
structure, otherwise an extra reference to external name is grabbed
(those are never modified).  In either case the pointer to stable
string is stored into the same structure.

dentry must be held by the caller of take_dentry_name_snapshot(),
but may be freely dropped afterwards - the snapshot will stay
until destroyed by release_dentry_name_snapshot().

Intended use:
	struct name_snapshot s;

	take_dentry_name_snapshot(&s, dentry);
	...
	access s.name
	...
	release_dentry_name_snapshot(&s);

Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name
to pass down with event.

BUG=chromium:754205
TEST=Build and run

Change-Id: Ic11a9c94b484d10ae8d7b04ec00ec0dd3e45ef59
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
(cherry picked from commit 49d31c2f389)
Reviewed-on: https://chromium-review.googlesource.com/610515
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
(cherry picked from commit 9cb7a61dceeb06c15a47ccdb57b9c5f66a588a1f)
Reviewed-on: https://chromium-review.googlesource.com/617418
6 files changed