Message ID | 156321360519.148361.2779156857011152900.stgit@magnolia (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iomap: regroup code by functional area | expand |
I wonder if this should go with the rest of the buffered I/O code into buffered-io.c? Yes, it would need an ifdef, but it is closely related to it in how we use the page private information. > diff --git a/fs/iomap/migrate.c b/fs/iomap/migrate.c > new file mode 100644 > index 000000000000..d8116d35f819 > --- /dev/null > +++ b/fs/iomap/migrate.c > @@ -0,0 +1,39 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2010 Red Hat, Inc. > + * Copyright (c) 2016-2018 Christoph Hellwig. > + */ Bit if you don't want to move it, this is all new code from me from 2018.
On Tue, Jul 16, 2019 at 10:05:03PM -0700, Christoph Hellwig wrote: > I wonder if this should go with the rest of the buffered I/O code into > buffered-io.c? Yes, it would need an ifdef, but it is closely related > to it in how we use the page private information. Hmmm, I suppose the fact that we need a page migration function that moves page_private from one page to another reflects what we do with pages, even though we don't explicitly dereference the page private pointer itself. > > diff --git a/fs/iomap/migrate.c b/fs/iomap/migrate.c > > new file mode 100644 > > index 000000000000..d8116d35f819 > > --- /dev/null > > +++ b/fs/iomap/migrate.c > > @@ -0,0 +1,39 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2010 Red Hat, Inc. > > + * Copyright (c) 2016-2018 Christoph Hellwig. > > + */ > > Bit if you don't want to move it, this is all new code from me from > 2018. Ok, will shove it all into buffered-io.c then. --D
diff --git a/fs/iomap.c b/fs/iomap.c index ab658a4b97d3..88a3144351a9 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -89,32 +89,3 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags, return written ? written : ret; } - -#ifdef CONFIG_MIGRATION -int -iomap_migrate_page(struct address_space *mapping, struct page *newpage, - struct page *page, enum migrate_mode mode) -{ - int ret; - - ret = migrate_page_move_mapping(mapping, newpage, page, mode, 0); - if (ret != MIGRATEPAGE_SUCCESS) - return ret; - - if (page_has_private(page)) { - ClearPagePrivate(page); - get_page(newpage); - set_page_private(newpage, page_private(page)); - set_page_private(page, 0); - put_page(page); - SetPagePrivate(newpage); - } - - if (mode != MIGRATE_SYNC_NO_COPY) - migrate_page_copy(newpage, page); - else - migrate_page_states(newpage, page); - return MIGRATEPAGE_SUCCESS; -} -EXPORT_SYMBOL_GPL(iomap_migrate_page); -#endif /* CONFIG_MIGRATION */ diff --git a/fs/iomap/Makefile b/fs/iomap/Makefile index d2a81819ae01..04cbeed44248 100644 --- a/fs/iomap/Makefile +++ b/fs/iomap/Makefile @@ -14,4 +14,5 @@ iomap-y += \ fiemap.o \ seek.o +iomap-$(CONFIG_MIGRATION) += migrate.o iomap-$(CONFIG_SWAP) += swapfile.o diff --git a/fs/iomap/migrate.c b/fs/iomap/migrate.c new file mode 100644 index 000000000000..d8116d35f819 --- /dev/null +++ b/fs/iomap/migrate.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2010 Red Hat, Inc. + * Copyright (c) 2016-2018 Christoph Hellwig. + */ +#include <linux/module.h> +#include <linux/compiler.h> +#include <linux/fs.h> +#include <linux/iomap.h> +#include <linux/migrate.h> + +#include "internal.h" + +int +iomap_migrate_page(struct address_space *mapping, struct page *newpage, + struct page *page, enum migrate_mode mode) +{ + int ret; + + ret = migrate_page_move_mapping(mapping, newpage, page, mode, 0); + if (ret != MIGRATEPAGE_SUCCESS) + return ret; + + if (page_has_private(page)) { + ClearPagePrivate(page); + get_page(newpage); + set_page_private(newpage, page_private(page)); + set_page_private(page, 0); + put_page(page); + SetPagePrivate(newpage); + } + + if (mode != MIGRATE_SYNC_NO_COPY) + migrate_page_copy(newpage, page); + else + migrate_page_states(newpage, page); + return MIGRATEPAGE_SUCCESS; +} +EXPORT_SYMBOL_GPL(iomap_migrate_page);