[RESEND PATCH 07/13] vfs: Remove full_fds_bits from fd allocation code path.

2017-07-11 Thread Sandhya Bankar
The IDR has removed the need to have full_fds_bits hence removing it.

Signed-off-by: Sandhya Bankar 
Signed-off-by: Matthew Wilcox 
---
 fs/file.c   | 18 +-
 include/linux/fdtable.h |  2 --
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index da3a35b..e8c6ada 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -56,9 +56,6 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
__free_fdtable(container_of(rcu, struct fdtable, rcu));
 }
 
-#define BITBIT_NR(nr)  BITS_TO_LONGS(BITS_TO_LONGS(nr))
-#define BITBIT_SIZE(nr)(BITBIT_NR(nr) * sizeof(long))
-
 /*
  * Copy 'count' fd bits from the old table to the new table and clear the extra
  * space if any.  This does not copy the file pointers.  Called with the files
@@ -75,11 +72,6 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct 
fdtable *ofdt,
memset((char *)nfdt->open_fds + cpy, 0, set);
memcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy);
memset((char *)nfdt->close_on_exec + cpy, 0, set);
-
-   cpy = BITBIT_SIZE(count);
-   set = BITBIT_SIZE(nfdt->max_fds) - cpy;
-   memcpy(nfdt->full_fds_bits, ofdt->full_fds_bits, cpy);
-   memset((char *)nfdt->full_fds_bits + cpy, 0, set);
 }
 
 /*
@@ -124,14 +116,12 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
fdt->max_fds = nr;
 
data = alloc_fdmem(max_t(size_t,
-2 * nr / BITS_PER_BYTE + BITBIT_SIZE(nr), 
L1_CACHE_BYTES));
+2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES));
if (!data)
goto out_fdt;
fdt->open_fds = data;
data += nr / BITS_PER_BYTE;
fdt->close_on_exec = data;
-   data += nr / BITS_PER_BYTE;
-   fdt->full_fds_bits = data;
 
return fdt;
 
@@ -246,15 +236,11 @@ static inline void __clear_close_on_exec(unsigned int fd, 
struct fdtable *fdt)
 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__set_bit(fd, fdt->open_fds);
-   fd /= BITS_PER_LONG;
-   if (!~fdt->open_fds[fd])
-   __set_bit(fd, fdt->full_fds_bits);
 }
 
 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__clear_bit(fd, fdt->open_fds);
-   __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
 }
 
 static unsigned int count_open_files(struct fdtable *fdt)
@@ -298,7 +284,6 @@ struct files_struct *dup_fd(struct files_struct *oldf, int 
*errorp)
new_fdt->max_fds = NR_OPEN_DEFAULT;
new_fdt->close_on_exec = newf->close_on_exec_init;
new_fdt->open_fds = newf->open_fds_init;
-   new_fdt->full_fds_bits = newf->full_fds_bits_init;
 
 restart:
idr_copy_preload(>fd_idr, GFP_KERNEL);
@@ -472,7 +457,6 @@ struct files_struct init_files = {
.max_fds= NR_OPEN_DEFAULT,
.close_on_exec  = init_files.close_on_exec_init,
.open_fds   = init_files.open_fds_init,
-   .full_fds_bits  = init_files.full_fds_bits_init,
},
.file_lock  = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
.fd_idr = IDR_INIT,
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index c2a53b6..6bece35 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -26,7 +26,6 @@ struct fdtable {
unsigned int max_fds;
unsigned long *close_on_exec;
unsigned long *open_fds;
-   unsigned long *full_fds_bits;
struct rcu_head rcu;
 };
 
@@ -60,7 +59,6 @@ struct files_struct {
spinlock_t file_lock cacheline_aligned_in_smp;
unsigned long close_on_exec_init[1];
unsigned long open_fds_init[1];
-   unsigned long full_fds_bits_init[1];
 };
 
 struct file_operations;
-- 
1.8.3.1



[RESEND PATCH 07/13] vfs: Remove full_fds_bits from fd allocation code path.

2017-07-11 Thread Sandhya Bankar
The IDR has removed the need to have full_fds_bits hence removing it.

Signed-off-by: Sandhya Bankar 
Signed-off-by: Matthew Wilcox 
---
 fs/file.c   | 18 +-
 include/linux/fdtable.h |  2 --
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index da3a35b..e8c6ada 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -56,9 +56,6 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
__free_fdtable(container_of(rcu, struct fdtable, rcu));
 }
 
-#define BITBIT_NR(nr)  BITS_TO_LONGS(BITS_TO_LONGS(nr))
-#define BITBIT_SIZE(nr)(BITBIT_NR(nr) * sizeof(long))
-
 /*
  * Copy 'count' fd bits from the old table to the new table and clear the extra
  * space if any.  This does not copy the file pointers.  Called with the files
@@ -75,11 +72,6 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct 
fdtable *ofdt,
memset((char *)nfdt->open_fds + cpy, 0, set);
memcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy);
memset((char *)nfdt->close_on_exec + cpy, 0, set);
-
-   cpy = BITBIT_SIZE(count);
-   set = BITBIT_SIZE(nfdt->max_fds) - cpy;
-   memcpy(nfdt->full_fds_bits, ofdt->full_fds_bits, cpy);
-   memset((char *)nfdt->full_fds_bits + cpy, 0, set);
 }
 
 /*
@@ -124,14 +116,12 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
fdt->max_fds = nr;
 
data = alloc_fdmem(max_t(size_t,
-2 * nr / BITS_PER_BYTE + BITBIT_SIZE(nr), 
L1_CACHE_BYTES));
+2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES));
if (!data)
goto out_fdt;
fdt->open_fds = data;
data += nr / BITS_PER_BYTE;
fdt->close_on_exec = data;
-   data += nr / BITS_PER_BYTE;
-   fdt->full_fds_bits = data;
 
return fdt;
 
@@ -246,15 +236,11 @@ static inline void __clear_close_on_exec(unsigned int fd, 
struct fdtable *fdt)
 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__set_bit(fd, fdt->open_fds);
-   fd /= BITS_PER_LONG;
-   if (!~fdt->open_fds[fd])
-   __set_bit(fd, fdt->full_fds_bits);
 }
 
 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__clear_bit(fd, fdt->open_fds);
-   __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
 }
 
 static unsigned int count_open_files(struct fdtable *fdt)
@@ -298,7 +284,6 @@ struct files_struct *dup_fd(struct files_struct *oldf, int 
*errorp)
new_fdt->max_fds = NR_OPEN_DEFAULT;
new_fdt->close_on_exec = newf->close_on_exec_init;
new_fdt->open_fds = newf->open_fds_init;
-   new_fdt->full_fds_bits = newf->full_fds_bits_init;
 
 restart:
idr_copy_preload(>fd_idr, GFP_KERNEL);
@@ -472,7 +457,6 @@ struct files_struct init_files = {
.max_fds= NR_OPEN_DEFAULT,
.close_on_exec  = init_files.close_on_exec_init,
.open_fds   = init_files.open_fds_init,
-   .full_fds_bits  = init_files.full_fds_bits_init,
},
.file_lock  = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
.fd_idr = IDR_INIT,
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index c2a53b6..6bece35 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -26,7 +26,6 @@ struct fdtable {
unsigned int max_fds;
unsigned long *close_on_exec;
unsigned long *open_fds;
-   unsigned long *full_fds_bits;
struct rcu_head rcu;
 };
 
@@ -60,7 +59,6 @@ struct files_struct {
spinlock_t file_lock cacheline_aligned_in_smp;
unsigned long close_on_exec_init[1];
unsigned long open_fds_init[1];
-   unsigned long full_fds_bits_init[1];
 };
 
 struct file_operations;
-- 
1.8.3.1



[PATCH 07/13] vfs: Remove full_fds_bits from fd allocation code path.

2017-04-29 Thread Sandhya Bankar
The IDR has removed the need to have full_fds_bits hence removing it.

Signed-off-by: Sandhya Bankar 
Signed-off-by: Matthew Wilcox 
---
 fs/file.c   | 18 +-
 include/linux/fdtable.h |  2 --
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index da3a35b..e8c6ada 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -56,9 +56,6 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
__free_fdtable(container_of(rcu, struct fdtable, rcu));
 }
 
-#define BITBIT_NR(nr)  BITS_TO_LONGS(BITS_TO_LONGS(nr))
-#define BITBIT_SIZE(nr)(BITBIT_NR(nr) * sizeof(long))
-
 /*
  * Copy 'count' fd bits from the old table to the new table and clear the extra
  * space if any.  This does not copy the file pointers.  Called with the files
@@ -75,11 +72,6 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct 
fdtable *ofdt,
memset((char *)nfdt->open_fds + cpy, 0, set);
memcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy);
memset((char *)nfdt->close_on_exec + cpy, 0, set);
-
-   cpy = BITBIT_SIZE(count);
-   set = BITBIT_SIZE(nfdt->max_fds) - cpy;
-   memcpy(nfdt->full_fds_bits, ofdt->full_fds_bits, cpy);
-   memset((char *)nfdt->full_fds_bits + cpy, 0, set);
 }
 
 /*
@@ -124,14 +116,12 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
fdt->max_fds = nr;
 
data = alloc_fdmem(max_t(size_t,
-2 * nr / BITS_PER_BYTE + BITBIT_SIZE(nr), 
L1_CACHE_BYTES));
+2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES));
if (!data)
goto out_fdt;
fdt->open_fds = data;
data += nr / BITS_PER_BYTE;
fdt->close_on_exec = data;
-   data += nr / BITS_PER_BYTE;
-   fdt->full_fds_bits = data;
 
return fdt;
 
@@ -246,15 +236,11 @@ static inline void __clear_close_on_exec(unsigned int fd, 
struct fdtable *fdt)
 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__set_bit(fd, fdt->open_fds);
-   fd /= BITS_PER_LONG;
-   if (!~fdt->open_fds[fd])
-   __set_bit(fd, fdt->full_fds_bits);
 }
 
 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__clear_bit(fd, fdt->open_fds);
-   __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
 }
 
 static unsigned int count_open_files(struct fdtable *fdt)
@@ -298,7 +284,6 @@ struct files_struct *dup_fd(struct files_struct *oldf, int 
*errorp)
new_fdt->max_fds = NR_OPEN_DEFAULT;
new_fdt->close_on_exec = newf->close_on_exec_init;
new_fdt->open_fds = newf->open_fds_init;
-   new_fdt->full_fds_bits = newf->full_fds_bits_init;
 
 restart:
idr_copy_preload(>fd_idr, GFP_KERNEL);
@@ -472,7 +457,6 @@ struct files_struct init_files = {
.max_fds= NR_OPEN_DEFAULT,
.close_on_exec  = init_files.close_on_exec_init,
.open_fds   = init_files.open_fds_init,
-   .full_fds_bits  = init_files.full_fds_bits_init,
},
.file_lock  = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
.fd_idr = IDR_INIT,
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index c2a53b6..6bece35 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -26,7 +26,6 @@ struct fdtable {
unsigned int max_fds;
unsigned long *close_on_exec;
unsigned long *open_fds;
-   unsigned long *full_fds_bits;
struct rcu_head rcu;
 };
 
@@ -60,7 +59,6 @@ struct files_struct {
spinlock_t file_lock cacheline_aligned_in_smp;
unsigned long close_on_exec_init[1];
unsigned long open_fds_init[1];
-   unsigned long full_fds_bits_init[1];
 };
 
 struct file_operations;
-- 
1.8.3.1



[PATCH 07/13] vfs: Remove full_fds_bits from fd allocation code path.

2017-04-29 Thread Sandhya Bankar
The IDR has removed the need to have full_fds_bits hence removing it.

Signed-off-by: Sandhya Bankar 
Signed-off-by: Matthew Wilcox 
---
 fs/file.c   | 18 +-
 include/linux/fdtable.h |  2 --
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index da3a35b..e8c6ada 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -56,9 +56,6 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
__free_fdtable(container_of(rcu, struct fdtable, rcu));
 }
 
-#define BITBIT_NR(nr)  BITS_TO_LONGS(BITS_TO_LONGS(nr))
-#define BITBIT_SIZE(nr)(BITBIT_NR(nr) * sizeof(long))
-
 /*
  * Copy 'count' fd bits from the old table to the new table and clear the extra
  * space if any.  This does not copy the file pointers.  Called with the files
@@ -75,11 +72,6 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct 
fdtable *ofdt,
memset((char *)nfdt->open_fds + cpy, 0, set);
memcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy);
memset((char *)nfdt->close_on_exec + cpy, 0, set);
-
-   cpy = BITBIT_SIZE(count);
-   set = BITBIT_SIZE(nfdt->max_fds) - cpy;
-   memcpy(nfdt->full_fds_bits, ofdt->full_fds_bits, cpy);
-   memset((char *)nfdt->full_fds_bits + cpy, 0, set);
 }
 
 /*
@@ -124,14 +116,12 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
fdt->max_fds = nr;
 
data = alloc_fdmem(max_t(size_t,
-2 * nr / BITS_PER_BYTE + BITBIT_SIZE(nr), 
L1_CACHE_BYTES));
+2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES));
if (!data)
goto out_fdt;
fdt->open_fds = data;
data += nr / BITS_PER_BYTE;
fdt->close_on_exec = data;
-   data += nr / BITS_PER_BYTE;
-   fdt->full_fds_bits = data;
 
return fdt;
 
@@ -246,15 +236,11 @@ static inline void __clear_close_on_exec(unsigned int fd, 
struct fdtable *fdt)
 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__set_bit(fd, fdt->open_fds);
-   fd /= BITS_PER_LONG;
-   if (!~fdt->open_fds[fd])
-   __set_bit(fd, fdt->full_fds_bits);
 }
 
 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
 {
__clear_bit(fd, fdt->open_fds);
-   __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
 }
 
 static unsigned int count_open_files(struct fdtable *fdt)
@@ -298,7 +284,6 @@ struct files_struct *dup_fd(struct files_struct *oldf, int 
*errorp)
new_fdt->max_fds = NR_OPEN_DEFAULT;
new_fdt->close_on_exec = newf->close_on_exec_init;
new_fdt->open_fds = newf->open_fds_init;
-   new_fdt->full_fds_bits = newf->full_fds_bits_init;
 
 restart:
idr_copy_preload(>fd_idr, GFP_KERNEL);
@@ -472,7 +457,6 @@ struct files_struct init_files = {
.max_fds= NR_OPEN_DEFAULT,
.close_on_exec  = init_files.close_on_exec_init,
.open_fds   = init_files.open_fds_init,
-   .full_fds_bits  = init_files.full_fds_bits_init,
},
.file_lock  = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
.fd_idr = IDR_INIT,
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index c2a53b6..6bece35 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -26,7 +26,6 @@ struct fdtable {
unsigned int max_fds;
unsigned long *close_on_exec;
unsigned long *open_fds;
-   unsigned long *full_fds_bits;
struct rcu_head rcu;
 };
 
@@ -60,7 +59,6 @@ struct files_struct {
spinlock_t file_lock cacheline_aligned_in_smp;
unsigned long close_on_exec_init[1];
unsigned long open_fds_init[1];
-   unsigned long full_fds_bits_init[1];
 };
 
 struct file_operations;
-- 
1.8.3.1