rattrs: Adopted LFS3_tag_RATTRS for LFS3_o_WRSET name creation

Here's one interesting use-case for the single-recurse LFS3_tag_RATTRS:
Avoiding a copy of the name creation rattrs in lfs3_file_sync_.

There is a concern with nesting LFS3_tag_RATTRS in that it risks
conflicts across layers, but currently this is ok as long as
high-level LFS3_tag_RATTRS stick to non-negative mids (the mtree split
commit in lfs3_mdir_commit_ only needs to recurse for mroot rattrs).

Saves a bit of code:

                 code          stack          ctx
  before:       35320           2176          660
  after:        35316 (-0.0%)   2176 (+0.0%)  660 (+0.0%)

                 code          stack          ctx
  gbmap before: 38172           2192          772
  gbmap after:  38168 (-0.0%)   2192 (+0.0%)  772 (+0.0%)
This commit is contained in:
Christopher Haster
2025-11-30 00:34:58 -06:00
parent 8db3ce342c
commit a96e2776cb
+4 -5
View File
@@ -12413,7 +12413,8 @@ int lfs3_file_opencfg_(lfs3_t *lfs3, lfs3_file_t *file,
LFS3_RATTR(4, LFS3_TAG_REG, +1, LFS3_FROM_NAME),
LFS3_RATTR_ARG(did),
LFS3_RATTR_ARG(path),
LFS3_RATTR_ARG(lfs3_path_namelen(path))));
LFS3_RATTR_ARG(lfs3_path_namelen(path)),
LFS3_RATTR_NULL));
if (err) {
goto failed;
}
@@ -14017,10 +14018,8 @@ static int lfs3_file_sync_(lfs3_t *lfs3, lfs3_file_t *file,
if (lfs3_o_isunsync(file->b.h.flags)) {
// explicit name?
if (rname) {
LFS3_ASSERT(lfs3_rattr_len(rname) <= 4);
for (lfs3_size_t i = 0; i < lfs3_rattr_len(rname); i++) {
*r++ = rname[i];
}
*r++ = LFS3_RATTR(2, LFS3_tag_RATTRS, +1);
*r++ = LFS3_RATTR_ARG(rname);
// not created yet? need to convert to normal file
} else if (lfs3_o_isuncreat(file->b.h.flags)) {