From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/3 RESEND Rebased] btrfs: add inode pointer to prop_handler::validate()
Date: Wed, 26 Jun 2019 16:34:00 +0800 [thread overview]
Message-ID: <20190626083402.1895-2-anand.jain@oracle.com> (raw)
In-Reply-To: <20190626083402.1895-1-anand.jain@oracle.com>
In preparation to add the readmirror property, pass inode in the
prop_handler::validate() function vector, so that it can fetch
corresponding fs_devices.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/props.c | 12 +++++++-----
fs/btrfs/props.h | 4 ++--
fs/btrfs/xattr.c | 2 +-
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index e0469816c678..f9143f7c006d 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -17,7 +17,7 @@ static DEFINE_HASHTABLE(prop_handlers_ht, BTRFS_PROP_HANDLERS_HT_BITS);
struct prop_handler {
struct hlist_node node;
const char *xattr_name;
- int (*validate)(const char *value, size_t len);
+ int (*validate)(struct inode *inode, const char *value, size_t len);
int (*apply)(struct inode *inode, const char *value, size_t len);
const char *(*extract)(struct inode *inode);
int inheritable;
@@ -55,7 +55,8 @@ find_prop_handler(const char *name,
return NULL;
}
-int btrfs_validate_prop(const char *name, const char *value, size_t value_len)
+int btrfs_validate_prop(struct inode *inode, const char *name,
+ const char *value, size_t value_len)
{
const struct prop_handler *handler;
@@ -69,7 +70,7 @@ int btrfs_validate_prop(const char *name, const char *value, size_t value_len)
if (value_len == 0)
return 0;
- return handler->validate(value, value_len);
+ return handler->validate(inode, value, value_len);
}
int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
@@ -252,7 +253,8 @@ int btrfs_load_inode_props(struct inode *inode, struct btrfs_path *path)
return ret;
}
-static int prop_compression_validate(const char *value, size_t len)
+static int prop_compression_validate(struct inode *inode, const char *value,
+ size_t len)
{
if (!value)
return 0;
@@ -350,7 +352,7 @@ static int inherit_props(struct btrfs_trans_handle *trans,
* This is not strictly necessary as the property should be
* valid, but in case it isn't, don't propagate it futher.
*/
- ret = h->validate(value, strlen(value));
+ ret = h->validate(inode, value, strlen(value));
if (ret)
continue;
diff --git a/fs/btrfs/props.h b/fs/btrfs/props.h
index 40b2c65b518c..5b1e39136f7f 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -13,8 +13,8 @@ void __init btrfs_props_init(void);
int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
const char *name, const char *value, size_t value_len,
int flags);
-int btrfs_validate_prop(const char *name, const char *value, size_t value_len);
-
+int btrfs_validate_prop(struct inode *inode, const char *name,
+ const char *value, size_t value_len);
int btrfs_load_inode_props(struct inode *inode, struct btrfs_path *path);
int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 95d9aebff2c4..9bfe179717d3 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -378,7 +378,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
struct btrfs_root *root = BTRFS_I(inode)->root;
name = xattr_full_name(handler, name);
- ret = btrfs_validate_prop(name, value, size);
+ ret = btrfs_validate_prop(inode, name, value, size);
if (ret)
return ret;
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-06-26 8:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 8:33 [PATCH 0/3 RESEND Rebased] readmirror feature Anand Jain
2019-06-26 8:34 ` Anand Jain [this message]
2019-06-26 8:34 ` [PATCH 2/3 RESEND Rebased] btrfs: add readmirror property framework Anand Jain
2019-07-23 14:57 ` David Sterba
2019-07-24 2:42 ` Anand Jain
2019-06-26 8:34 ` [PATCH 3/3 RESEND Rebased] btrfs: add readmirror devid property Anand Jain
2019-07-23 14:55 ` David Sterba
2019-07-23 15:25 ` David Sterba
2019-06-26 8:37 ` [PATCH 1/2 RESEND Rebased] btrfs-progs: add helper to create xattr name Anand Jain
2019-06-26 8:37 ` [PATCH 2/2 RESEND Rebased] btrfs-progs: add readmirror policy Anand Jain
2019-07-23 13:53 ` David Sterba
2019-07-24 3:11 ` Anand Jain
2019-07-23 13:55 ` David Sterba
2019-07-02 8:09 ` [PATCH 0/3 RESEND Rebased] readmirror feature Anand Jain
2019-07-24 0:20 ` Qu Wenruo
2019-07-24 2:26 ` Anand Jain
2019-07-24 3:05 ` Qu Wenruo
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=20190626083402.1895-2-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).