From: James Bottomley <James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
To: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: "Kweh,
Hock Leong"
<hock.leong.kweh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [RFC 1/3] sysfs,kernfs: add flush operation
Date: Wed, 29 Apr 2015 16:09:45 -0700 [thread overview]
Message-ID: <1430348985.2189.39.camel@HansenPartnership.com> (raw)
In-Reply-To: <1430348859.2189.37.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
From: James Bottomley <JBottomley-O3H1v1f1dlM@public.gmane.org>
This is necessary to allow sysfs operations to return error in close (we are
using close to initiate and return a possible error from a transaction).
Signed-off-by: James Bottomley <JBottomley-O3H1v1f1dlM@public.gmane.org>
---
fs/kernfs/file.c | 16 ++++++++++++++++
fs/sysfs/file.c | 16 ++++++++++++++++
include/linux/kernfs.h | 2 ++
include/linux/sysfs.h | 2 ++
4 files changed, 36 insertions(+)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 2bacb99..d9bc8d7 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -802,6 +802,21 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
return DEFAULT_POLLMASK|POLLERR|POLLPRI;
}
+static int kernfs_fop_flush(struct file *file, fl_owner_t id)
+{
+ struct kernfs_open_file *of = kernfs_of(file);
+ const struct kernfs_ops *ops;
+ int rc = 0;
+
+ mutex_lock(&of->mutex);
+ ops = kernfs_ops(of->kn);
+ if (ops->flush)
+ rc = ops->flush(of, id);
+ mutex_unlock(&of->mutex);
+
+ return rc;
+}
+
static void kernfs_notify_workfn(struct work_struct *work)
{
struct kernfs_node *kn;
@@ -891,6 +906,7 @@ const struct file_operations kernfs_file_fops = {
.open = kernfs_fop_open,
.release = kernfs_fop_release,
.poll = kernfs_fop_poll,
+ .flush = kernfs_fop_flush,
};
/**
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 7c2867b..188639f 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -162,6 +162,19 @@ static int sysfs_kf_bin_mmap(struct kernfs_open_file *of,
return battr->mmap(of->file, kobj, battr, vma);
}
+static int sysfs_kf_bin_flush(struct kernfs_open_file *of,
+ fl_owner_t id)
+{
+ struct bin_attribute *battr = of->kn->priv;
+ struct kobject *kobj = of->kn->parent->priv;
+ int rc = 0;
+
+ if (battr->flush)
+ rc = battr->flush(of->file, kobj, battr, id);
+
+ return rc;
+}
+
void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr)
{
struct kernfs_node *kn = kobj->sd, *tmp;
@@ -222,17 +235,20 @@ static const struct kernfs_ops sysfs_bin_kfops_ro = {
static const struct kernfs_ops sysfs_bin_kfops_wo = {
.write = sysfs_kf_bin_write,
+ .flush = sysfs_kf_bin_flush,
};
static const struct kernfs_ops sysfs_bin_kfops_rw = {
.read = sysfs_kf_bin_read,
.write = sysfs_kf_bin_write,
+ .flush = sysfs_kf_bin_flush,
};
static const struct kernfs_ops sysfs_bin_kfops_mmap = {
.read = sysfs_kf_bin_read,
.write = sysfs_kf_bin_write,
.mmap = sysfs_kf_bin_mmap,
+ .flush = sysfs_kf_bin_flush,
};
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 71ecdab..ead781c 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -11,6 +11,7 @@
#include <linux/err.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/fs.h>
#include <linux/idr.h>
#include <linux/lockdep.h>
#include <linux/rbtree.h>
@@ -225,6 +226,7 @@ struct kernfs_ops {
loff_t off);
int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma);
+ int (*flush) (struct kernfs_open_file *of, fl_owner_t id);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lock_class_key lockdep_key;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 99382c0..391da13 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -152,6 +152,8 @@ struct bin_attribute {
char *, loff_t, size_t);
int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
struct vm_area_struct *vma);
+ int (*flush)(struct file *, struct kobject *,
+ struct bin_attribute *attr, fl_owner_t id);
};
/**
--
2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: linux-efi@vger.kernel.org
Cc: "Kweh, Hock Leong" <hock.leong.kweh@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Andy Lutomirski <luto@amacapital.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Peter Jones <pjones@redhat.com>
Subject: [RFC 1/3] sysfs,kernfs: add flush operation
Date: Wed, 29 Apr 2015 16:09:45 -0700 [thread overview]
Message-ID: <1430348985.2189.39.camel@HansenPartnership.com> (raw)
In-Reply-To: <1430348859.2189.37.camel@HansenPartnership.com>
From: James Bottomley <JBottomley@Odin.com>
This is necessary to allow sysfs operations to return error in close (we are
using close to initiate and return a possible error from a transaction).
Signed-off-by: James Bottomley <JBottomley@Odin.com>
---
fs/kernfs/file.c | 16 ++++++++++++++++
fs/sysfs/file.c | 16 ++++++++++++++++
include/linux/kernfs.h | 2 ++
include/linux/sysfs.h | 2 ++
4 files changed, 36 insertions(+)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 2bacb99..d9bc8d7 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -802,6 +802,21 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
return DEFAULT_POLLMASK|POLLERR|POLLPRI;
}
+static int kernfs_fop_flush(struct file *file, fl_owner_t id)
+{
+ struct kernfs_open_file *of = kernfs_of(file);
+ const struct kernfs_ops *ops;
+ int rc = 0;
+
+ mutex_lock(&of->mutex);
+ ops = kernfs_ops(of->kn);
+ if (ops->flush)
+ rc = ops->flush(of, id);
+ mutex_unlock(&of->mutex);
+
+ return rc;
+}
+
static void kernfs_notify_workfn(struct work_struct *work)
{
struct kernfs_node *kn;
@@ -891,6 +906,7 @@ const struct file_operations kernfs_file_fops = {
.open = kernfs_fop_open,
.release = kernfs_fop_release,
.poll = kernfs_fop_poll,
+ .flush = kernfs_fop_flush,
};
/**
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 7c2867b..188639f 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -162,6 +162,19 @@ static int sysfs_kf_bin_mmap(struct kernfs_open_file *of,
return battr->mmap(of->file, kobj, battr, vma);
}
+static int sysfs_kf_bin_flush(struct kernfs_open_file *of,
+ fl_owner_t id)
+{
+ struct bin_attribute *battr = of->kn->priv;
+ struct kobject *kobj = of->kn->parent->priv;
+ int rc = 0;
+
+ if (battr->flush)
+ rc = battr->flush(of->file, kobj, battr, id);
+
+ return rc;
+}
+
void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr)
{
struct kernfs_node *kn = kobj->sd, *tmp;
@@ -222,17 +235,20 @@ static const struct kernfs_ops sysfs_bin_kfops_ro = {
static const struct kernfs_ops sysfs_bin_kfops_wo = {
.write = sysfs_kf_bin_write,
+ .flush = sysfs_kf_bin_flush,
};
static const struct kernfs_ops sysfs_bin_kfops_rw = {
.read = sysfs_kf_bin_read,
.write = sysfs_kf_bin_write,
+ .flush = sysfs_kf_bin_flush,
};
static const struct kernfs_ops sysfs_bin_kfops_mmap = {
.read = sysfs_kf_bin_read,
.write = sysfs_kf_bin_write,
.mmap = sysfs_kf_bin_mmap,
+ .flush = sysfs_kf_bin_flush,
};
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 71ecdab..ead781c 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -11,6 +11,7 @@
#include <linux/err.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/fs.h>
#include <linux/idr.h>
#include <linux/lockdep.h>
#include <linux/rbtree.h>
@@ -225,6 +226,7 @@ struct kernfs_ops {
loff_t off);
int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma);
+ int (*flush) (struct kernfs_open_file *of, fl_owner_t id);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lock_class_key lockdep_key;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 99382c0..391da13 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -152,6 +152,8 @@ struct bin_attribute {
char *, loff_t, size_t);
int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
struct vm_area_struct *vma);
+ int (*flush)(struct file *, struct kobject *,
+ struct bin_attribute *attr, fl_owner_t id);
};
/**
--
2.1.4
next prev parent reply other threads:[~2015-04-29 23:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 23:07 [RFC 0/3] Add capsule update using error on close semantics James Bottomley
[not found] ` <1430348859.2189.37.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-04-29 23:09 ` James Bottomley [this message]
2015-04-29 23:09 ` [RFC 1/3] sysfs,kernfs: add flush operation James Bottomley
2015-04-30 13:11 ` Greg Kroah-Hartman
2015-04-30 14:52 ` James Bottomley
2015-04-29 23:10 ` [RFC 2/3] firmware_class: split out transaction helpers James Bottomley
2015-04-29 23:10 ` James Bottomley
[not found] ` <1430349052.2189.41.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-04-30 13:11 ` Greg Kroah-Hartman
2015-04-30 13:11 ` Greg Kroah-Hartman
2015-04-30 14:39 ` James Bottomley
2015-08-27 14:47 ` Matt Fleming
2015-08-27 16:25 ` James Bottomley
[not found] ` <1440692717.2196.123.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-08-27 19:43 ` Matt Fleming
2015-08-27 19:43 ` Matt Fleming
2015-04-29 23:12 ` [RFC 3/3] efi: add capsule update capability via sysfs James Bottomley
[not found] ` <1430349130.2189.43.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-04-29 23:25 ` Andy Lutomirski
2015-04-29 23:25 ` Andy Lutomirski
[not found] ` <CALCETrV8bRj_CmCwZfHSV8bMF-vv0sab_7v5t0rpdhx2ib=wPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-29 23:36 ` James Bottomley
2015-04-29 23:36 ` James Bottomley
[not found] ` <1430350592.2189.50.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-04-29 23:39 ` Andy Lutomirski
2015-04-29 23:39 ` Andy Lutomirski
2015-04-30 9:30 ` [RFC 0/3] Add capsule update using error on close semantics Kweh, Hock Leong
2015-04-30 9:30 ` Kweh, Hock Leong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430348985.2189.39.camel@HansenPartnership.com \
--to=james.bottomley-d9phhud1jfjcxq6kfmz53/egyhegw8jk@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hock.leong.kweh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org \
--cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.