You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "JosiahWI (via GitHub)" <gi...@apache.org> on 2025/01/08 01:31:00 UTC
[PR] Make directory operations methods on `Directory` [trafficserver]
JosiahWI opened a new pull request, #11945:
URL: https://github.com/apache/trafficserver/pull/11945
These operations are working with directory data. Right now, they operate on data of type `Stripe` or `StripeSM`, but that was because those data structures contained the directory data they needed until recently. Most of the other data there is irrelevant.
This PR moves those operations (see commits for the list) into the `Directory` structure to reduce the dependence on the irrelevant parts of `Stripe` and `StripeSM`.
The `StripeSMs` are needed in some cases for debugging, metrics, and an intriguing invocation of `Stripe::dir_valid` from `dir_probe`; the `Directory` structure will need to be adjusted to have access to a few things for those purposes, but the details of that are still a work in progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#issuecomment-2910719345
Rebased on master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2150362436
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -304,14 +304,14 @@ check_dir(Stripe *stripe)
}
inline void
-unlink_from_freelist(Dir *e, int s, Stripe *stripe)
+unlink_from_freelist(Dir *e, int s, Directory *directory)
Review Comment:
I looked for the functions that were operations on the directory, and I might have missed this one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI merged PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "masaori335 (via GitHub)" <gi...@apache.org>.
masaori335 commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2149013206
##########
src/iocore/cache/Cache.cc:
##########
@@ -342,7 +342,7 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, st
CacheVC *c = nullptr;
{
CACHE_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding);
- if (!lock.is_locked() || (od = stripe->open_read(key)) || dir_probe(key, stripe, &result, &last_collision)) {
+ if (!lock.is_locked() || (od = stripe->open_read(key)) || stripe->directory.probe(key, stripe, &result, &last_collision)) {
Review Comment:
Note for later refactoring: this can be like this?
```
stripe->dir_probe(key, &result, &last_collision)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "masaori335 (via GitHub)" <gi...@apache.org>.
masaori335 commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2149020733
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -304,14 +304,14 @@ check_dir(Stripe *stripe)
}
inline void
-unlink_from_freelist(Dir *e, int s, Stripe *stripe)
+unlink_from_freelist(Dir *e, int s, Directory *directory)
Review Comment:
Similar to above. Would you share me what's the policy of which function should be moved to `Directory` or not here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2150368176
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -217,41 +217,41 @@ dir_bucket_loop_check(Dir *start_dir, Dir *seg)
// adds all the directory entries
// in a segment to the segment freelist
void
-dir_init_segment(int s, Stripe *stripe)
+dir_init_segment(int s, Directory *directory)
{
- stripe->directory.header->freelist[s] = 0;
- Dir *seg = stripe->directory.get_segment(s);
+ directory->header->freelist[s] = 0;
+ Dir *seg = directory->get_segment(s);
int l, b;
- memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * stripe->directory.buckets);
+ memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * directory->buckets);
for (l = 1; l < DIR_DEPTH; l++) {
- for (b = 0; b < stripe->directory.buckets; b++) {
+ for (b = 0; b < directory->buckets; b++) {
Dir *bucket = dir_bucket(b, seg);
- dir_free_entry(dir_bucket_row(bucket, l), s, stripe);
+ directory->free_entry(dir_bucket_row(bucket, l), s);
}
}
}
// break the infinite loop in directory entries
// Note : abuse of the token bit in dir entries
int
-dir_bucket_loop_fix(Dir *start_dir, int s, Stripe *stripe)
+dir_bucket_loop_fix(Dir *start_dir, int s, Directory *directory)
Review Comment:
I think `dir_init_segment` can be a method of `Directory` as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#issuecomment-2910724812
I have not removed the dependency of `Directory` on `StripeSM` or `Stripe`, but after looking at this multiple times, I'm not sure it's a good idea to try to force that. It would be nice to have a cleaner dependency structure, but we should aim to simplify things, not add complexity. This PR cleans up some call sites and makes it clearer what data is required to carry out each operation. Therefore, I think it is a good change as-is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2150366303
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -217,41 +217,41 @@ dir_bucket_loop_check(Dir *start_dir, Dir *seg)
// adds all the directory entries
// in a segment to the segment freelist
void
-dir_init_segment(int s, Stripe *stripe)
+dir_init_segment(int s, Directory *directory)
{
- stripe->directory.header->freelist[s] = 0;
- Dir *seg = stripe->directory.get_segment(s);
+ directory->header->freelist[s] = 0;
+ Dir *seg = directory->get_segment(s);
int l, b;
- memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * stripe->directory.buckets);
+ memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * directory->buckets);
for (l = 1; l < DIR_DEPTH; l++) {
- for (b = 0; b < stripe->directory.buckets; b++) {
+ for (b = 0; b < directory->buckets; b++) {
Dir *bucket = dir_bucket(b, seg);
- dir_free_entry(dir_bucket_row(bucket, l), s, stripe);
+ directory->free_entry(dir_bucket_row(bucket, l), s);
}
}
}
// break the infinite loop in directory entries
// Note : abuse of the token bit in dir entries
int
-dir_bucket_loop_fix(Dir *start_dir, int s, Stripe *stripe)
+dir_bucket_loop_fix(Dir *start_dir, int s, Directory *directory)
Review Comment:
Definitely, I missed this opportunity. Very easy improvement for further refactoring. Thanks for catching it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#issuecomment-2731056133
[approve ci autest 2]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "masaori335 (via GitHub)" <gi...@apache.org>.
masaori335 commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2149014582
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -217,41 +217,41 @@ dir_bucket_loop_check(Dir *start_dir, Dir *seg)
// adds all the directory entries
// in a segment to the segment freelist
void
-dir_init_segment(int s, Stripe *stripe)
+dir_init_segment(int s, Directory *directory)
{
- stripe->directory.header->freelist[s] = 0;
- Dir *seg = stripe->directory.get_segment(s);
+ directory->header->freelist[s] = 0;
+ Dir *seg = directory->get_segment(s);
int l, b;
- memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * stripe->directory.buckets);
+ memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * directory->buckets);
for (l = 1; l < DIR_DEPTH; l++) {
- for (b = 0; b < stripe->directory.buckets; b++) {
+ for (b = 0; b < directory->buckets; b++) {
Dir *bucket = dir_bucket(b, seg);
- dir_free_entry(dir_bucket_row(bucket, l), s, stripe);
+ directory->free_entry(dir_bucket_row(bucket, l), s);
}
}
}
// break the infinite loop in directory entries
// Note : abuse of the token bit in dir entries
int
-dir_bucket_loop_fix(Dir *start_dir, int s, Stripe *stripe)
+dir_bucket_loop_fix(Dir *start_dir, int s, Directory *directory)
Review Comment:
Can we make this function a member of `Directory` too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make directory operations methods on `Directory` [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11945:
URL: https://github.com/apache/trafficserver/pull/11945#discussion_r2150370527
##########
src/iocore/cache/CacheDir.cc:
##########
@@ -304,14 +304,14 @@ check_dir(Stripe *stripe)
}
inline void
-unlink_from_freelist(Dir *e, int s, Stripe *stripe)
+unlink_from_freelist(Dir *e, int s, Directory *directory)
Review Comment:
Yeah, this should be moved. I see what happened. I only moved the public interface, and not any helper functions. Further refactoring should make all these helper functions private methods on `Directory`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org