diff --git a/include/linux/mm.h b/include/linux/mm.h
index 26adfcc0d61a1bd953ba0f3b47d78e37e5840848..77a76101dcd996c26d284b10274af21b091bbb16 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -785,6 +785,7 @@ extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
 extern void do_invalidatepage(struct page *page, unsigned long offset);
 
 int __set_page_dirty_nobuffers(struct page *page);
+int __set_page_dirty_no_writeback(struct page *page);
 int redirty_page_for_writepage(struct writeback_control *wbc,
 				struct page *page);
 int FASTCALL(set_page_dirty(struct page *page));
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index be0efbde4994f5454198384ce274b62eb827adc4..438833cbbca4daf01f09ef9a20860cc87c5dbe78 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -736,6 +736,16 @@ int write_one_page(struct page *page, int wait)
 }
 EXPORT_SYMBOL(write_one_page);
 
+/*
+ * For address_spaces which do not use buffers nor write back.
+ */
+int __set_page_dirty_no_writeback(struct page *page)
+{
+	if (!PageDirty(page))
+		SetPageDirty(page);
+	return 0;
+}
+
 /*
  * For address_spaces which do not use buffers.  Just tag the page as dirty in
  * its radix tree.
diff --git a/mm/shmem.c b/mm/shmem.c
index 70da7a0981bfbad9683b5e9b0747277256a678ff..b38e17169271b3664dd35f7281048eb116ef37b1 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2316,7 +2316,7 @@ static void destroy_inodecache(void)
 
 static const struct address_space_operations shmem_aops = {
 	.writepage	= shmem_writepage,
-	.set_page_dirty	= __set_page_dirty_nobuffers,
+	.set_page_dirty	= __set_page_dirty_no_writeback,
 #ifdef CONFIG_TMPFS
 	.prepare_write	= shmem_prepare_write,
 	.commit_write	= simple_commit_write,