@@ -290,7 +290,6 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio)
290
290
if (unlikely (cmpxchg (& inode -> i_wb , NULL , wb )))
291
291
wb_put (wb );
292
292
}
293
- EXPORT_SYMBOL_GPL (__inode_attach_wb );
294
293
295
294
/**
296
295
* inode_cgwb_move_to_attached - put the inode onto wb->b_attached list
@@ -731,8 +730,8 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
731
730
* writeback completion, wbc_detach_inode() should be called. This is used
732
731
* to track the cgroup writeback context.
733
732
*/
734
- void wbc_attach_and_unlock_inode (struct writeback_control * wbc ,
735
- struct inode * inode )
733
+ static void wbc_attach_and_unlock_inode (struct writeback_control * wbc ,
734
+ struct inode * inode )
736
735
__releases (& inode - > i_lock )
737
736
{
738
737
if (!inode_cgwb_enabled (inode )) {
@@ -763,7 +762,24 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
763
762
if (unlikely (wb_dying (wbc -> wb ) && !css_is_dying (wbc -> wb -> memcg_css )))
764
763
inode_switch_wbs (inode , wbc -> wb_id );
765
764
}
766
- EXPORT_SYMBOL_GPL (wbc_attach_and_unlock_inode );
765
+
766
+ /**
767
+ * wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite
768
+ * @wbc: writeback_control of interest
769
+ * @inode: target inode
770
+ *
771
+ * This function is to be used by __filemap_fdatawrite_range(), which is an
772
+ * alternative entry point into writeback code, and first ensures @inode is
773
+ * associated with a bdi_writeback and attaches it to @wbc.
774
+ */
775
+ void wbc_attach_fdatawrite_inode (struct writeback_control * wbc ,
776
+ struct inode * inode )
777
+ {
778
+ spin_lock (& inode -> i_lock );
779
+ inode_attach_wb (inode , NULL );
780
+ wbc_attach_and_unlock_inode (wbc , inode );
781
+ }
782
+ EXPORT_SYMBOL_GPL (wbc_attach_fdatawrite_inode );
767
783
768
784
/**
769
785
* wbc_detach_inode - disassociate wbc from inode and perform foreign detection
@@ -1228,6 +1244,13 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
1228
1244
}
1229
1245
}
1230
1246
1247
+ static inline void wbc_attach_and_unlock_inode (struct writeback_control * wbc ,
1248
+ struct inode * inode )
1249
+ __releases (& inode - > i_lock )
1250
+ {
1251
+ spin_unlock (& inode -> i_lock );
1252
+ }
1253
+
1231
1254
#endif /* CONFIG_CGROUP_WRITEBACK */
1232
1255
1233
1256
/*
0 commit comments