In a Chapter 7 bankruptcy filing, your second mortgage probably won’t be discharged, which means you’re still responsible for repaying it, and the lender can foreclose on your home to get paid.
A Chapter 13 bankruptcy allows for “lien stripping,” which removes junior liens on your home. Since your first mortgage takes priority, you may be able to have the debt from your second mortgage discharged — once you complete your repayment plan — and have the second mortgage lien removed. This could be especially helpful if your home is underwater.