From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, hch@infradead.org, Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 16/19] fs: add unlocked helpers
Date: Fri, 22 Oct 2010 21:35:01 +0400 [thread overview]
Message-ID: <1287768904-27810-17-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1287768904-27810-1-git-send-email-dmonakhov@openvz.org>
inode_{add,sub}_bytes will be used by dquot code
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/quota/dquot.c | 50 ++++++++++++++++++++++++++++++++++++++------------
fs/stat.c | 15 ++++++++++++---
include/linux/fs.h | 2 ++
3 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 9779800..1c7eea1 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -240,6 +240,7 @@ struct dqstats dqstats;
EXPORT_SYMBOL(dqstats);
static qsize_t inode_get_rsv_space(struct inode *inode);
+static qsize_t __inode_get_rsv_space(struct inode *inode);
static void __dquot_initialize(struct inode *inode, int type);
static inline unsigned int
@@ -1553,11 +1554,17 @@ void inode_add_rsv_space(struct inode *inode, qsize_t number)
}
EXPORT_SYMBOL(inode_add_rsv_space);
-void inode_claim_rsv_space(struct inode *inode, qsize_t number)
+inline void __inode_claim_rsv_space(struct inode *inode, qsize_t number)
{
- spin_lock(&inode->i_lock);
*inode_reserved_space(inode) -= number;
__inode_add_bytes(inode, number);
+
+}
+
+void inode_claim_rsv_space(struct inode *inode, qsize_t number)
+{
+ spin_lock(&inode->i_lock);
+ __inode_claim_rsv_space(inode, number);
spin_unlock(&inode->i_lock);
}
EXPORT_SYMBOL(inode_claim_rsv_space);
@@ -1570,33 +1577,52 @@ void inode_sub_rsv_space(struct inode *inode, qsize_t number)
}
EXPORT_SYMBOL(inode_sub_rsv_space);
-static qsize_t inode_get_rsv_space(struct inode *inode)
+static qsize_t __inode_get_rsv_space(struct inode *inode)
{
- qsize_t ret;
-
if (!dqctl(inode->i_sb)->dq_op->get_reserved_space)
return 0;
+ return *inode_reserved_space(inode);
+}
+
+static qsize_t inode_get_rsv_space(struct inode *inode)
+{
+ qsize_t ret;
spin_lock(&inode->i_lock);
- ret = *inode_reserved_space(inode);
+ ret = __inode_get_rsv_space(inode);
spin_unlock(&inode->i_lock);
return ret;
}
-static void inode_incr_space(struct inode *inode, qsize_t number,
+static void __inode_incr_space(struct inode *inode, qsize_t number,
int reserve)
{
if (reserve)
- inode_add_rsv_space(inode, number);
+ *inode_reserved_space(inode) += number;
else
- inode_add_bytes(inode, number);
+ __inode_add_bytes(inode, number);
}
-static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
+static void inode_incr_space(struct inode *inode, qsize_t number,
+ int reserve)
+{
+ spin_lock(&inode->i_lock);
+ __inode_incr_space(inode, number, reserve);
+ spin_unlock(&inode->i_lock);
+}
+
+
+static void __inode_decr_space(struct inode *inode, qsize_t number, int reserve)
{
if (reserve)
- inode_sub_rsv_space(inode, number);
+ *inode_reserved_space(inode) -= number;
else
- inode_sub_bytes(inode, number);
+ __inode_sub_bytes(inode, number);
+}
+static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
+{
+ spin_lock(&inode->i_lock);
+ __inode_decr_space(inode, number, reserve);
+ spin_unlock(&inode->i_lock);
}
/*
diff --git a/fs/stat.c b/fs/stat.c
index 12e90e2..f2da983 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -429,9 +429,8 @@ void inode_add_bytes(struct inode *inode, loff_t bytes)
EXPORT_SYMBOL(inode_add_bytes);
-void inode_sub_bytes(struct inode *inode, loff_t bytes)
+void __inode_sub_bytes(struct inode *inode, loff_t bytes)
{
- spin_lock(&inode->i_lock);
inode->i_blocks -= bytes >> 9;
bytes &= 511;
if (inode->i_bytes < bytes) {
@@ -439,17 +438,27 @@ void inode_sub_bytes(struct inode *inode, loff_t bytes)
inode->i_bytes += 512;
}
inode->i_bytes -= bytes;
+}
+
+void inode_sub_bytes(struct inode *inode, loff_t bytes)
+{
+ spin_lock(&inode->i_lock);
+ __inode_sub_bytes(inode, bytes);
spin_unlock(&inode->i_lock);
}
EXPORT_SYMBOL(inode_sub_bytes);
+inline loff_t __inode_get_bytes(struct inode *inode)
+{
+ return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
+}
loff_t inode_get_bytes(struct inode *inode)
{
loff_t ret;
spin_lock(&inode->i_lock);
- ret = (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
+ ret = __inode_get_bytes(inode);
spin_unlock(&inode->i_lock);
return ret;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e87694a..3ef2ec1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2308,7 +2308,9 @@ extern void generic_fillattr(struct inode *, struct kstat *);
extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
void __inode_add_bytes(struct inode *inode, loff_t bytes);
void inode_add_bytes(struct inode *inode, loff_t bytes);
+void __inode_sub_bytes(struct inode *inode, loff_t bytes);
void inode_sub_bytes(struct inode *inode, loff_t bytes);
+loff_t __inode_get_bytes(struct inode *inode);
loff_t inode_get_bytes(struct inode *inode);
void inode_set_bytes(struct inode *inode, loff_t bytes);
--
1.6.5.2
next prev parent reply other threads:[~2010-10-22 17:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 17:34 [PATCH 00/19] quota: RFC SMP improvements for generic quota V2 Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 01/19] quota: protect getfmt call with dqonoff_mutex lock Dmitry Monakhov
2010-10-28 14:27 ` Christoph Hellwig
2010-10-22 17:34 ` [PATCH 02/19] quota: Wrap common expression to helper function Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 03/19] quota: mode quota internals from sb to quota_info Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 04/19] quota: Convert dq_state_lock to per-sb dq_state_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 05/19] quota: add quota format lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 06/19] quota: make dquot lists per-sb Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 07/19] quota: make per-sb hash array Dmitry Monakhov
2010-10-27 19:31 ` Al Viro
2010-10-28 10:58 ` Dmitry
2010-10-22 17:34 ` [PATCH 08/19] quota: remove global dq_list_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 09/19] quota: rename dq_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 10/19] quota: make per-sb dq_data_lock Dmitry Monakhov
2010-10-26 17:38 ` Dmitry
2010-10-22 17:34 ` [PATCH 11/19] quota: protect dquot mem info with object's lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 12/19] quota: drop dq_data_lock where possible Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 13/19] quota: relax dq_data_lock dq_lock locking consistency Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 14/19] quota: protect dqget() from parallels quotaoff via RCU Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 15/19] quota: remove dq_state_lock Dmitry Monakhov
2010-10-22 17:35 ` Dmitry Monakhov [this message]
2010-10-22 17:35 ` [PATCH 17/19] quota: Some stylistic cleanup for dquot interface Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 18/19] quota: remove dqptr_sem Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 19/19] quota: redesign dquot reference counting Dmitry Monakhov
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=1287768904-27810-17-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@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).