[Devel] [PATCH 10/10] e4defrag2: fixup IAF fragmentation conditions
Dmitry Monakhov
dmonakhov at openvz.org
Thu Feb 25 02:54:33 PST 2016
By default we assumes that file is not fragmented is it's
average fragment is less than 64k. It is not alwasys good to
skip such files. Let's do fix such files.
This patch switch single file fragmentation criteria from 64k to 256k
For example some DB does random IO which result in very fragmented file.
File size of /mnt/0/var/prometheus/data/c9/30306a52349207.db is 6704040 (1637 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 372: 8629248.. 8629620: 373:
1: 373.. 382: 8820288.. 8820297: 10: 8629621:
2: 383.. 389: 8689714.. 8689720: 7: 8820298:
3: 390.. 399: 8591391.. 8591400: 10: 8689721:
4: 400.. 402: 8689806.. 8689808: 3: 8591401:
5: 403.. 415: 8692785.. 8692797: 13: 8689809:
6: 416.. 427: 8687230.. 8687241: 12: 8692798:
7: 428.. 437: 8692874.. 8692883: 10: 8687242:
8: 438.. 444: 8492207.. 8492213: 7: 8692884:
9: 445.. 451: 7872939.. 7872945: 7: 8492214:
10: 452.. 464: 6264239.. 6264251: 13: 7872946:
11: 465.. 467: 7873041.. 7873043: 3: 6264252:
12: 468.. 483: 9373122.. 9373137: 16: 7873044:
13: 484.. 511: 9309218.. 9309245: 28: 9373138:
14: 512.. 1023: 9656832.. 9657343: 512: 9309246:
15: 1024.. 1046: 9907200.. 9907222: 23: 9657344:
16: 1047.. 1054: 14165762.. 14165769: 8: 9907223:
17: 1055.. 1067: 14166667.. 14166679: 13: 14165770:
18: 1068.. 1073: 14166843.. 14166848: 6: 14166680:
19: 1074.. 1084: 14167512.. 14167522: 11: 14166849:
20: 1085.. 1097: 14168314.. 14168326: 13: 14167523:
21: 1098.. 1101: 14168556.. 14168559: 4: 14168327:
22: 1102.. 1134: 14521315.. 14521347: 33: 14168560:
23: 1135.. 1145: 14586700.. 14586710: 11: 14521348:
24: 1146.. 1155: 14617563.. 14617572: 10: 14586711:
25: 1156.. 1163: 14749160.. 14749167: 8: 14617573:
26: 1164.. 1173: 14689185.. 14689194: 10: 14749168:
27: 1174.. 1183: 14689451.. 14689460: 10: 14689195:
28: 1184.. 1189: 14622351.. 14622356: 6: 14689461:
29: 1190.. 1193: 14591187.. 14591190: 4: 14622357:
30: 1194.. 1201: 14689716.. 14689723: 8: 14591191:
31: 1202.. 1210: 2635598.. 2635606: 9: 14689724:
32: 1211.. 1221: 14691113.. 14691123: 11: 2635607:
33: 1222.. 1226: 14691157.. 14691161: 5: 14691124:
34: 1227.. 1229: 14691182.. 14691184: 3: 14691162:
35: 1230.. 1231: 14691207.. 14691208: 2: 14691185:
36: 1232.. 1239: 14691260.. 14691267: 8: 14691209:
37: 1240.. 1247: 15376588.. 15376595: 8: 14691268:
38: 1248.. 1253: 14691321.. 14691326: 6: 15376596:
39: 1254.. 1268: 14691425.. 14691439: 15: 14691327:
40: 1269.. 1271: 14691446.. 14691448: 3: 14691440:
41: 1272.. 1289: 14691645.. 14691662: 18: 14691449:
42: 1290.. 1291: 17610.. 17611: 2: 14691663:
43: 1292.. 1301: 14691762.. 14691771: 10: 17612:
44: 1302.. 1311: 14691807.. 14691816: 10: 14691772:
45: 1312.. 1327: 14691859.. 14691874: 16: 14691817:
46: 1328.. 1333: 14691898.. 14691903: 6: 14691875:
47: 1334.. 1338: 14691906.. 14691910: 5: 14691904:
48: 1339.. 1349: 14691937.. 14691947: 11: 14691911:
49: 1350.. 1360: 466112.. 466122: 11: 14691948:
50: 1361.. 1364: 14692011.. 14692014: 4: 466123:
51: 1365.. 1418: 14692037.. 14692090: 54: 14692015:
52: 1419.. 1433: 15536214.. 15536228: 15: 14692091:
53: 1434.. 1442: 12591514.. 12591522: 9: 15536229:
54: 1443.. 1447: 12596509.. 12596513: 5: 12591523:
55: 1448.. 1456: 15218457.. 15218465: 9: 12596514:
56: 1457.. 1465: 12596791.. 12596799: 9: 15218466:
57: 1466.. 1475: 12596875.. 12596884: 10: 12596800:
58: 1476.. 1484: 12596999.. 12597007: 9: 12596885:
59: 1485.. 1493: 15218854.. 15218862: 9: 12597008:
60: 1494.. 1502: 426355.. 426363: 9: 15218863:
61: 1503.. 1507: 12597201.. 12597205: 5: 426364:
62: 1508.. 1515: 12597318.. 12597325: 8: 12597206:
63: 1516.. 1531: 3679921.. 3679936: 16: 12597326:
64: 1532.. 1536: 6829273.. 6829277: 5: 3679937:
65: 1537.. 1543: 14692514.. 14692520: 7: 6829278:
66: 1544.. 1552: 3680331.. 3680339: 9: 14692521:
67: 1553.. 1570: 3681055.. 3681072: 18: 3680340:
68: 1571.. 1585: 3681765.. 3681779: 15: 3681073:
69: 1586.. 1595: 3681946.. 3681955: 10: 3681780:
70: 1596.. 1599: 233383.. 233386: 4: 3681956:
71: 1600.. 1636: 6829915.. 6829951: 37: 233387: eof
/mnt/0/var/prometheus/data/c9/30306a52349207.db: 72 extents found
https://jira.sw.ru/browse/PSBM-42954
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
misc/e4defrag2.c | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/misc/e4defrag2.c b/misc/e4defrag2.c
index 5738a75..e5239db 100644
--- a/misc/e4defrag2.c
+++ b/misc/e4defrag2.c
@@ -1890,22 +1890,30 @@ static int check_iaf(struct defrag_context *dfx, struct stat64 *stat,
{
__u64 eof_lblk;
//// FIXME free_space_average should be tunable
- __u64 free_space_average = 16;
+ __u64 free_space_average = 64;
+ int ret = 1;
if (!S_ISREG(stat->st_mode))
- return 0;
+ ret = 0;
if (fec->fec_extents < 2)
- return 0;
+ ret = 0;
if (fest->hole)
- return 0;
+ ret = 0;
+
eof_lblk = fec->fec_map[fec->fec_extents -1].lblk +
fec->fec_map[fec->fec_extents -1].len;
if (eof_lblk / fest->frag > free_space_average)
- return 0;
+ ret = 0;
- return 1;
+
+ if (debug_flag & DBG_RT)
+ printf("%s ino:%ld frag:%d eof_blk:%lld free_space_aver:%d ret:%d\n",
+ __FUNCTION__, stat->st_ino, eof_lblk, fest->frag,
+ free_space_average, ret);
+
+ return ret;
}
@@ -2007,7 +2015,7 @@ static int do_iaf_defrag_one(struct defrag_context *dfx, int dirfd, const char *
/* Force local group for small files
* FIXME: This should be tunable
*/
- force_local = eof_lblk < 16;
+ force_local = eof_lblk < 4;
if (debug_flag & DBG_SCAN) {
int i;
@@ -2015,10 +2023,9 @@ static int do_iaf_defrag_one(struct defrag_context *dfx, int dirfd, const char *
__func__, stat->st_ino, (unsigned long long) eof_lblk,
force_local, fest->frag, fest->local_ex);
for (i = 0; i < fec->fec_extents; i++)
- printf("%llu ->[%u, %u] %llu [%u, %u]\n",
- eof_lblk, force_local,
- fec->fec_map[i].lblk, fec->fec_map[i].pblk,
- fec->fec_map[i].len, fest->local_ex);
+ printf("%u [%u, %u] -> %llu [%u, %u]\n",
+ i, fec->fec_map[i].lblk, fec->fec_map[i].len,
+ fec->fec_map[i].pblk);
}
ret = prepare_donor(dfx, ino_grp, &donor, eof_lblk, force_local, fest->frag / 2);
@@ -2036,10 +2043,11 @@ static int do_iaf_defrag_one(struct defrag_context *dfx, int dirfd, const char *
force_local, fest->frag, fest->local_ex);
for (i = 0; i < donor.fec->fec_extents; i++)
- printf("%llu ->[%u, %u] EX:%llu [%u, %u]\n",
- (unsigned long long)eof_lblk, force_local,
- donor.fec->fec_map[i].lblk, donor.fec->fec_map[i].pblk,
- donor.fec->fec_map[i].len, donor.fest.local_ex);
+ printf("%u [%u, %u] -> %llu [%u, %u]\n",
+ i, donor.fec->fec_map[i].lblk,
+ donor.fec->fec_map[i].len,
+ donor.fec->fec_map[i].pblk);
+
}
defrag_fadvise(fd, 0 , eof_lblk << dfx->blocksize_bits, 1);
--
1.8.3.1
More information about the Devel
mailing list