+static unsigned int osd_extent_bytes(const struct osd_device *o)
+{
+ unsigned int *extent_bytes_ptr =
+ raw_cpu_ptr(o->od_extent_bytes_percpu);
+
+ if (likely(*extent_bytes_ptr))
+ return *extent_bytes_ptr;
+
+ /* initialize on first access or CPU hotplug */
+ if (!ldiskfs_has_feature_extents(osd_sb(o)))
+ *extent_bytes_ptr = 1 << osd_sb(o)->s_blocksize_bits;
+ else
+ *extent_bytes_ptr = OSD_DEFAULT_EXTENT_BYTES;
+
+ return *extent_bytes_ptr;
+}
+
+#define EXTENT_BYTES_DECAY 64
+static void osd_decay_extent_bytes(struct osd_device *osd,
+ unsigned int new_bytes)
+{
+ unsigned int old_bytes;
+
+ if (!ldiskfs_has_feature_extents(osd_sb(osd)))
+ return;
+
+ old_bytes = osd_extent_bytes(osd);
+ *raw_cpu_ptr(osd->od_extent_bytes_percpu) =
+ (old_bytes * (EXTENT_BYTES_DECAY - 1) +
+ min(new_bytes, OSD_DEFAULT_EXTENT_BYTES) +
+ EXTENT_BYTES_DECAY - 1) / EXTENT_BYTES_DECAY;
+}