From Tolkien Gateway

The so-called Lockholes were the storage tunnels of Michel Delving, converted into prison cells when the Shire was taken over by Sharkey's Men during the War of the Ring.[1] In them were kept those who rebelled against the new regime, among whose inhabitants were Mayor Will Whitfoot, Lobelia Sackville-Baggins, and Fredegar "Fatty" Bolger.

On 4 November T.A. 3019, the day after the Battle of Bywater, Frodo rode to the Lockholes and released all of the prisoners. Those kept in the Lockholes were treated to harsh conditions and starved. Fredegar was no longer fat; in fact Pippin had to help him to walk out. Lobelia looked old and thin although she was able to hobble out on her own two feet; still, she died a few months later. Will Whitfoot was debilitated enough that Frodo took on the job of Deputy Mayor until Will could regain his strength.[2]

In Samwise Gamgee's poem, Perry-the-Winkle,[3] the Lonely Troll sat and wept outside of the Lockholes gate because he had no friends. There Perry-the-Winkle befriended the Troll who in gratitude took him home where they had a "fulsome tea". The inclusion of the word Lockholes indicates that Sam wrote the poem after the War of the Ring.[4]