linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: add roundup_to_blocksize and bytes_to_blocks helper functions
@ 2009-04-19 18:42 Marcin Slusarz
  2009-04-19 18:51 ` [PATCH] filesystems: start using roundup_to_blocksize and bytes_to_blocks Marcin Slusarz
  2009-04-22 21:10 ` [PATCH] fs: add roundup_to_blocksize and bytes_to_blocks helper functions Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Marcin Slusarz @ 2009-04-19 18:42 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: LKML

bytes_to_blocks is open coded in more than 30 places
roundup_to_blocksize is open coded in more than 15 places

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
---
 include/linux/fs.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index e766be0..1b4e5b6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2451,5 +2451,17 @@ int proc_nr_files(struct ctl_table *table, int write, struct file *filp,
 
 int get_filesystem_list(char * buf);
 
+static inline
+unsigned long long roundup_to_blocksize(unsigned long long bytes, struct super_block *sb)
+{
+	return (bytes + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
+}
+
+static inline
+blkcnt_t bytes_to_blocks(unsigned long long bytes, struct super_block *sb)
+{
+	return (bytes + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_FS_H */
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-04-26 17:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-19 18:42 [PATCH] fs: add roundup_to_blocksize and bytes_to_blocks helper functions Marcin Slusarz
2009-04-19 18:51 ` [PATCH] filesystems: start using roundup_to_blocksize and bytes_to_blocks Marcin Slusarz
2009-04-20 19:07   ` Dave Kleikamp
2009-04-20 20:22     ` Dave Kleikamp
2009-04-22 21:10 ` [PATCH] fs: add roundup_to_blocksize and bytes_to_blocks helper functions Andrew Morton
2009-04-22 21:40   ` Dave Kleikamp
2009-04-22 21:52     ` Andrew Morton
2009-04-26 17:21   ` Marcin Slusarz

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).