linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] adjustments for 5.8
@ 2020-08-16  9:35 Janpieter Sollie
  2020-08-16  9:46 ` [PATCH][2/2] " Janpieter Sollie
  0 siblings, 1 reply; 2+ messages in thread
From: Janpieter Sollie @ 2020-08-16  9:35 UTC (permalink / raw)
  To: linux-bcachefs

Hi,


Hereby some patches for review of the implementation of v5.8

I explicitly included the KERNEL_VERSION header (which is probably not needed, since it's an
in-tree driver) as the current version is 5.7, so once the 5.8 bump has been applied, the
KERNEL_VERSION statement should be removed.


Janpieter


diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index a0d570f3adf0..cdc85423826c 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -7,6 +7,7 @@
 #include "btree_locking.h"
 #include "debug.h"
 
+#include <linux/version.h>
 #include <linux/prefetch.h>
 #include <linux/sched/mm.h>
 #include <trace/events/bcachefs.h>
@@ -85,8 +86,12 @@ static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp)
        if (!b->data)
                return -ENOMEM;
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
        b->aux_data = __vmalloc(btree_aux_data_bytes(b), gfp,
                                PAGE_KERNEL_EXEC);
+#else
+       b->aux_data = __vmalloc(btree_aux_data_bytes(b), gfp);
+#endif
        if (!b->aux_data) {
                kvpfree(b->data, btree_bytes(c));
                b->data = NULL;
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index d73cc8ddadac..8b4bb75344ba 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -10,6 +10,7 @@
 #include "journal_reclaim.h"
 
 #include <trace/events/bcachefs.h>
+#include <linux/version.h>
 
 static int bch2_btree_key_cache_cmp_fn(struct rhashtable_compare_arg *arg,
                                       const void *obj)
@@ -391,7 +392,11 @@ static void btree_key_cache_journal_flush(struct journal *j,
        struct btree_trans trans;
 
        six_lock_read(&ck->c.lock, NULL, NULL);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
        key = READ_ONCE(ck->key);
+#else
+       key = __READ_ONCE(ck->key);
+#endif
 
        if (ck->journal.seq != seq ||
            !test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index 951a436195ee..b4f73d9e74ea 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -20,11 +20,15 @@
 #include "quota.h"
 #include "reflink.h"
 
+#include <linux/version.h>
 #include <linux/aio.h>
 #include <linux/backing-dev.h>
 #include <linux/falloc.h>
 #include <linux/migrate.h>
 #include <linux/mmu_context.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0))
+#include <linux/kthread.h>
+#endif
 #include <linux/pagevec.h>
 #include <linux/sched/signal.h>
 #include <linux/task_io_accounting_ops.h>
@@ -1819,7 +1823,11 @@ static long bch2_dio_write_loop(struct dio_write *dio)
 
        while (1) {
                if (kthread)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
                        use_mm(dio->mm);
+#else
+                       kthread_use_mm(dio->mm);
+#endif
                BUG_ON(current->faults_disabled_mapping);
                current->faults_disabled_mapping = mapping;
 
@@ -1827,8 +1835,11 @@ static long bch2_dio_write_loop(struct dio_write *dio)
 
                current->faults_disabled_mapping = NULL;
                if (kthread)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
                        unuse_mm(dio->mm);
-
+#else
+                       kthread_unuse_mm(dio->mm);
+#endif
                if (unlikely(ret < 0))
                        goto err;
 
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index a47923d67f7a..865619d0d2f0 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -22,6 +22,7 @@
 #include "super.h"
 #include "xattr.h"
 
+#include <linux/fiemap.h>
 #include <linux/aio.h>
 #include <linux/backing-dev.h>
 #include <linux/exportfs.h>
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 4dcd28456e00..4ae1d2a82ea6 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -2,6 +2,7 @@
 #ifndef _BCACHEFS_UTIL_H
 #define _BCACHEFS_UTIL_H
 
+#include <linux/version.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/closure.h>
@@ -99,7 +100,11 @@ static inline void *vpmalloc(size_t size, gfp_t gfp_mask)
 {
        return (void *) __get_free_pages(gfp_mask|__GFP_NOWARN,
                                         get_order(size)) ?:
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
                __vmalloc(size, gfp_mask, PAGE_KERNEL);
+#else
+               __vmalloc(size, gfp_mask);
+#endif
 }
 
 static inline void kvpfree(void *p, size_t size)


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

* Re: [PATCH][2/2] adjustments for 5.8
  2020-08-16  9:35 [PATCH] adjustments for 5.8 Janpieter Sollie
@ 2020-08-16  9:46 ` Janpieter Sollie
  0 siblings, 0 replies; 2+ messages in thread
From: Janpieter Sollie @ 2020-08-16  9:46 UTC (permalink / raw)
  To: linux-bcachefs

in order to restore functionality of the add_to_page_cache_vec in file mm/filemap.c, the follow
patch should also be applied:


diff --git a/mm/filemap.c b/mm/filemap.c
index d39a3f28d6a9..d58e1bc46d3b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -903,8 +904,8 @@ static int add_to_page_cache_vec(struct page **pages, unsigned nr_pages,
                VM_BUG_ON_PAGE(PageSwapCache(page), page);
 
                if (!PageHuge(page)) {
-                       error = mem_cgroup_try_charge(page, current->mm,
-                                                     gfp_mask, &memcg, false);
+                       error = mem_cgroup_charge(page, current->mm,
+                                                     gfp_mask);
                        if (error) {
                                if (!i)
                                        return error;
@@ -928,10 +929,6 @@ static int add_to_page_cache_vec(struct page **pages, unsigned nr_pages,
 
        for (i = 0; i < nr_added; i++) {
                struct page *page = pages[i];
-
-               if (!PageHuge(page))
-                       mem_cgroup_commit_charge(page, memcg, false, false);
-
                trace_mm_filemap_add_to_page_cache(page);
        }
 
@@ -939,7 +936,7 @@ static int add_to_page_cache_vec(struct page **pages, unsigned nr_pages,
                struct page *page = pages[i];
 
                if (!PageHuge(page))
-                       mem_cgroup_cancel_charge(page, memcg, false);
+                       mem_cgroup_uncharge(page);
 
                /* Leave page->index set: truncation relies upon it */
                page->mapping = NULL;


Op 2020-08-16 om 11:35 schreef Janpieter Sollie:
> Hi,
>
>
> Hereby some patches for review of the implementation of v5.8
>
> I explicitly included the KERNEL_VERSION header (which is probably not needed, since it's an
> in-tree driver) as the current version is 5.7, so once the 5.8 bump has been applied, the
> KERNEL_VERSION statement should be removed.
>
>
> Janpieter
>
>
> diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
> index a0d570f3adf0..cdc85423826c 100644
> --- a/fs/bcachefs/btree_cache.c
> +++ b/fs/bcachefs/btree_cache.c
> @@ -7,6 +7,7 @@
>  #include "btree_locking.h"
>  #include "debug.h"
>  
> +#include <linux/version.h>
>  #include <linux/prefetch.h>
>  #include <linux/sched/mm.h>
>  #include <trace/events/bcachefs.h>
> @@ -85,8 +86,12 @@ static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp)
>         if (!b->data)
>                 return -ENOMEM;
>  
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>         b->aux_data = __vmalloc(btree_aux_data_bytes(b), gfp,
>                                 PAGE_KERNEL_EXEC);
> +#else
> +       b->aux_data = __vmalloc(btree_aux_data_bytes(b), gfp);
> +#endif
>         if (!b->aux_data) {
>                 kvpfree(b->data, btree_bytes(c));
>                 b->data = NULL;
> diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
> index d73cc8ddadac..8b4bb75344ba 100644
> --- a/fs/bcachefs/btree_key_cache.c
> +++ b/fs/bcachefs/btree_key_cache.c
> @@ -10,6 +10,7 @@
>  #include "journal_reclaim.h"
>  
>  #include <trace/events/bcachefs.h>
> +#include <linux/version.h>
>  
>  static int bch2_btree_key_cache_cmp_fn(struct rhashtable_compare_arg *arg,
>                                        const void *obj)
> @@ -391,7 +392,11 @@ static void btree_key_cache_journal_flush(struct journal *j,
>         struct btree_trans trans;
>  
>         six_lock_read(&ck->c.lock, NULL, NULL);
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>         key = READ_ONCE(ck->key);
> +#else
> +       key = __READ_ONCE(ck->key);
> +#endif
>  
>         if (ck->journal.seq != seq ||
>             !test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
> diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
> index 951a436195ee..b4f73d9e74ea 100644
> --- a/fs/bcachefs/fs-io.c
> +++ b/fs/bcachefs/fs-io.c
> @@ -20,11 +20,15 @@
>  #include "quota.h"
>  #include "reflink.h"
>  
> +#include <linux/version.h>
>  #include <linux/aio.h>
>  #include <linux/backing-dev.h>
>  #include <linux/falloc.h>
>  #include <linux/migrate.h>
>  #include <linux/mmu_context.h>
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0))
> +#include <linux/kthread.h>
> +#endif
>  #include <linux/pagevec.h>
>  #include <linux/sched/signal.h>
>  #include <linux/task_io_accounting_ops.h>
> @@ -1819,7 +1823,11 @@ static long bch2_dio_write_loop(struct dio_write *dio)
>  
>         while (1) {
>                 if (kthread)
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>                         use_mm(dio->mm);
> +#else
> +                       kthread_use_mm(dio->mm);
> +#endif
>                 BUG_ON(current->faults_disabled_mapping);
>                 current->faults_disabled_mapping = mapping;
>  
> @@ -1827,8 +1835,11 @@ static long bch2_dio_write_loop(struct dio_write *dio)
>  
>                 current->faults_disabled_mapping = NULL;
>                 if (kthread)
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>                         unuse_mm(dio->mm);
> -
> +#else
> +                       kthread_unuse_mm(dio->mm);
> +#endif
>                 if (unlikely(ret < 0))
>                         goto err;
>  
> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> index a47923d67f7a..865619d0d2f0 100644
> --- a/fs/bcachefs/fs.c
> +++ b/fs/bcachefs/fs.c
> @@ -22,6 +22,7 @@
>  #include "super.h"
>  #include "xattr.h"
>  
> +#include <linux/fiemap.h>
>  #include <linux/aio.h>
>  #include <linux/backing-dev.h>
>  #include <linux/exportfs.h>
> diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
> index 4dcd28456e00..4ae1d2a82ea6 100644
> --- a/fs/bcachefs/util.h
> +++ b/fs/bcachefs/util.h
> @@ -2,6 +2,7 @@
>  #ifndef _BCACHEFS_UTIL_H
>  #define _BCACHEFS_UTIL_H
>  
> +#include <linux/version.h>
>  #include <linux/bio.h>
>  #include <linux/blkdev.h>
>  #include <linux/closure.h>
> @@ -99,7 +100,11 @@ static inline void *vpmalloc(size_t size, gfp_t gfp_mask)
>  {
>         return (void *) __get_free_pages(gfp_mask|__GFP_NOWARN,
>                                          get_order(size)) ?:
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0))
>                 __vmalloc(size, gfp_mask, PAGE_KERNEL);
> +#else
> +               __vmalloc(size, gfp_mask);
> +#endif
>  }
>  
>  static inline void kvpfree(void *p, size_t size)
>


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

end of thread, other threads:[~2020-08-16  9:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16  9:35 [PATCH] adjustments for 5.8 Janpieter Sollie
2020-08-16  9:46 ` [PATCH][2/2] " Janpieter Sollie

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